Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs elaborated info #4732

Merged
merged 4 commits into from
Oct 26, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions website/src/components/index-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ const deployableEnvs = [
href: '/docs/getting-started/deploy-mesh-gateway#mesh-as-an-koa-route',
},
{
name: 'Sveltekit',
name: 'SvelteKit',
href: '/docs/getting-started/deploy-mesh-gateway#mesh-and-sveltekit',
},
{
Expand Down Expand Up @@ -285,7 +285,7 @@ export function IndexPage(): ReactElement {
),
},
{
title: 'Omnigraph',
title: 'OmniGraph',
description: 'GraphQL Mesh compose sources as a single GraphQL schema',
icon: (
<Image
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ We already saw that `mesh dev` could be used for local development.

Similarly, Mesh provides a `mesh start` CLI command for production environments.

`mesh start` can be used for all environments supporting starting a webserver (Heroku, Digital Ocean, etc).
`mesh start` can be used for all environments supporting starting a web server (Heroku, Digital Ocean, etc).

Setup Mesh on a Serverless environment requires some integration work, detailed below.

Expand Down Expand Up @@ -194,7 +194,7 @@ app.use(async (ctx) => {
})
```

### Mesh and Sveltekit
### Mesh and SvelteKit

Similarly to regular and Vercel deployment, we will need to add the `mesh build` command in the build step.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Z[Mesh Gateway GraphQL API]
Z --> G;
```

Once again, GraphQL Mesh gots you covered with the `@graphql-mesh/json-schema` handler that will help provide a definition of the API.
Once again, GraphQL Mesh gets you covered with the `@graphql-mesh/json-schema` handler that will help provide a definition of the API.

## An overview of the `jsonSchema` handler

Expand Down Expand Up @@ -89,7 +89,7 @@ curl --location --request GET 'http://localhost:3002/books/1' > packages/single-
Which will create the following [`packages/single-source-no-source-definition/samples/book-1.json`](https://github.com/charlypoly/graphql-mesh-docs-first-gateway/tree/master/packages/single-source-no-source-definition/samples/book-1.json) file:

```json filename="book-1.json"
{ "id": "1", "title": "Dune", "authorId": "0", "categorieId": "0" }
{ "id": "1", "title": "Dune", "authorId": "0", "categoryId": "0" }
```

We can now provide use this sample file to configure our `Query.book` operation as follows [`.meshrc.yaml`](https://github.com/charlypoly/graphql-mesh-docs-first-gateway/tree/master/packages/single-source-no-source-definition/.meshrc.yaml):
Expand Down Expand Up @@ -127,7 +127,7 @@ type query_book {
id: String
title: String
authorId: String
categorieId: String
categoryId: String
}
```

Expand Down Expand Up @@ -184,7 +184,7 @@ type Book {
id: String
title: String
authorId: String
categorieId: String
categoryId: String
}
```

Expand Down Expand Up @@ -274,7 +274,7 @@ For example, our previous `POST /books` endpoint could return a totally differen
"id": "1",
"title": "Dune",
"authorId": "0",
"categorieId": "0"
"categoryId": "0"
}
```

Expand All @@ -293,7 +293,7 @@ For example, our previous `POST /books` endpoint could return a totally differen
"id": "1",
"title": "Dune",
"authorId": "0",
"categorieId": "0"
"categoryId": "0"
}
}
```
Expand Down Expand Up @@ -425,5 +425,5 @@ operations:
404:
responseSchema: ...
200:
responseSchmea: ...
responseSchema: ...
```
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ You can try out the following Query:
{
books {
authorId
categorieId
categoryId
id
title
}
Expand Down Expand Up @@ -236,7 +236,7 @@ And open your favorite web browser at [http://0.0.0.0:4000](http://0.0.0.0:4000)
books {
id
title
categorieId
categoryId
}
booksCategories {
id
Expand Down
5 changes: 4 additions & 1 deletion website/src/pages/docs/guides/auth0.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,10 @@ As expected the value of the `authInfo` field is `null`, as we are not passing a

## Generating an Auth0 Access Token

In order to retrieve an access token, we first need to set up an Auth0 application and an authentication route. For the sake of this guide and in order to reduce complexity we will simply add an route to our Mesh http server that renders some HTML with a `<script>` tag that invokes the Auth0 JavaScript SDK (referenced via a CDN) and then appends the authentication token to the document body. It should still give you a feeling how you can integrate the Auth0 SDK with your favorite Frontend Framework. If you are using Next.js you should check out [nextjs-auth0](https://github.com/auth0/nextjs-auth0).
In order to retrieve an access token, we first need to set up an Auth0 application and an authentication route.
For the sake of this guide and in order to reduce complexity we will simply add an route to our Mesh http server that renders some HTML with a `<script>` tag that invokes the Auth0 JavaScript SDK (referenced via a CDN) and then appends the authentication token to the document body.
It should still give you a feeling how you can integrate the Auth0 SDK with your favorite Frontend Framework.
If you are using Next.js you should check out [nextjs-auth0](https://github.com/auth0/nextjs-auth0).

Let's go back into the Auth0 interface on the Applications page.

Expand Down
2 changes: 1 addition & 1 deletion website/src/pages/docs/guides/extending-unified-schema.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ Any SDK method take the following arguments:
- `selectionSet`: allows to specify a selection on the Query/Mutation to fetch nested data
- `valuesFromResults`: allows to provide a function to transform the results (if the result is an array, the function will be mapped to each element)

<Callout>Note: `valuesFromResults`, compared to `selectionSet` helps to "flatten"/"unnest" data from results</Callout>
<Callout>Note: `valuesFromResults`, compared to `selectionSet` helps to "flatten"/"un-nest" data from results</Callout>

## Going further

Expand Down
2 changes: 1 addition & 1 deletion website/src/pages/docs/handlers/json-schema.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ sources:
Any JSON sample file can be used.
```

## Codesandbox Example
## CodeSandBox Example

You can check out our example that uses the JSON Schema handler with mock data.

Expand Down
2 changes: 1 addition & 1 deletion website/src/pages/docs/handlers/odata.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ sources:
Authorization: Bearer {env.MY_API_TOKEN}
```

## Codesandbox Example
## CodeSandBox Example

You can check out our TripPin example that uses the OData handler.

Expand Down
2 changes: 1 addition & 1 deletion website/src/pages/docs/handlers/openapi.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ We have a lot of examples for OpenAPI Handler;
- [StackExchange](https://codesandbox.io/s/github/Urigo/graphql-mesh/tree/master/examples/openapi-stackexchange)
- [Stripe](https://codesandbox.io/s/github/Urigo/graphql-mesh/tree/master/examples/openapi-stripe)
- [Subscriptions Example with Webhooks](https://codesandbox.io/s/github/Urigo/graphql-mesh/tree/master/examples/openapi-subscriptions)
- [Youtrack](https://codesandbox.io/s/github/Urigo/graphql-mesh/tree/master/examples/openapi-youtrack)
- [YouTrack](https://codesandbox.io/s/github/Urigo/graphql-mesh/tree/master/examples/openapi-youtrack)

## Config API Reference

Expand Down
2 changes: 1 addition & 1 deletion website/src/pages/docs/handlers/postgraphile.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ sources:
example on GitHub](https://github.com/Urigo/graphql-mesh/tree/master/examples/postgres-geodb).
</Callout>

## External Plugins (e.g. FederationPlugin, PgManyToManyPlugin, PostgisPlugin)
## External Plugins (e.g. FederationPlugin, PgManyToManyPlugin, PostGISPlugin)

You can add [PostGraphile plugins](https://graphile.org/postgraphile/community-plugins) for example FederationPlugin. You can install it like below:

Expand Down
2 changes: 1 addition & 1 deletion website/src/pages/docs/handlers/soap.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ sources:
wsdl: http://webservices.oorsprong.org/websamples.countryinfo/CountryInfoService.wso?WSDL
```

## Codesandbox Example
## CodeSandBox Example

You can check out our example that uses SOAP Handler.

Expand Down
2 changes: 1 addition & 1 deletion website/src/pages/docs/handlers/tuql.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ sources:
infile: path/to/db_dump.sql
```

## Codesandbox Example
## CodeSandBox Example

You can check out our example that uses Tuql Handler.

Expand Down
2 changes: 1 addition & 1 deletion website/src/pages/docs/plugins/http-cache.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Usually server environments don't have browser's HTTP caching logic.
This plugin brings [HTTP Caching](https://developer.mozilla.org/en-US/docs/Web/HTTP/Caching) to your GraphQL Mesh gateway.

<Callout>
The defined cache storage will be used for this plugin. By default, GraphQL Mesh uses [Localforage](/docs/cache/localforage) as a cache storage.
The defined cache storage will be used for this plugin. By default, GraphQL Mesh uses [LocalForage](/docs/cache/localforage) as a cache storage.
For example, you need to follow this section to configure [Redis](/docs/cache/redis) as your cache storage.
You can find other options under the same category.
</Callout>
Expand Down
2 changes: 1 addition & 1 deletion website/src/pages/docs/plugins/live-queries.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ import API from '../../../generated-markdown/ResponseCacheConfig.generated.md'

<API />

## Codesandbox Example
## CodeSandBox Example

<Callout>
You can learn more about [GraphQL Live Query](https://github.com/n1ru4l/graphql-live-query) in its documentation. You
Expand Down
2 changes: 1 addition & 1 deletion website/src/pages/docs/plugins/mock.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ module.exports = {

<Callout>Learn more about GraphQL Tools Mocking https://graphql-tools.com/docs/mocking</Callout>

## Codesandbox Example
## CodeSandBox Example

You can check out our example that uses the JSON Schema handler with mock data.

Expand Down
2 changes: 1 addition & 1 deletion website/src/pages/docs/plugins/response-caching.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ import API from '../../../generated-markdown/ResponseCacheConfig.generated.md'

<API />

## Codesandbox Example
## CodeSandBox Example

You can check the ["Location Weather" example](https://github.com/Urigo/graphql-mesh/tree/master/examples/openapi-location-weather/) that uses OpenAPI handler with cache transform;

Expand Down
2 changes: 1 addition & 1 deletion website/src/pages/docs/plugins/snapshot.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ The following snapshot will work if you are in a development environment (see th

To modify your snapshots and change the responses, go to `__snapshots__` and modify the responses under those files.

## Codesandbox Example
## CodeSandBox Example

You can check out our example that uses SOAP Handler with snapshot plugin.

Expand Down
4 changes: 2 additions & 2 deletions website/src/pages/docs/transforms/cache.mdx.bak
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ To get started with this transform, install it:
<PackageCmd packages={['@graphql-mesh/transform-cache']} />

<Callout>
GraphQL Mesh uses a default localforage cache (it is fallback to LRU cache in NodeJS), but you can replace it with any other key=>value cache mechanism. See [cache section](/docs/cache/localforage) for more info.
GraphQL Mesh uses a default localForage cache (it is fallback to LRU cache in NodeJS), but you can replace it with any other key=>value cache mechanism. See [cache section](/docs/cache/localforage) for more info.
We'd recommend this transform be used on the root level, not the handler level. It might not work as expected if you use it on a handler level.

</Callout>
Expand Down Expand Up @@ -136,7 +136,7 @@ const { schema, execute, cache } = getBuiltMesh()
cache.delete(SOME_KEY)
```

## Codesandbox Example
## CodeSandBox Example

You can check the ["Location Weather" example](https://github.com/Urigo/graphql-mesh/tree/master/examples/openapi-location-weather/) that uses OpenAPI handler with cache transform;

Expand Down
9 changes: 8 additions & 1 deletion website/src/pages/docs/transforms/filter-schema.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ import { PackageCmd, Callout } from '@theguild/components'

# Filter Schema Transform

The `filterSchema` transform allows you to filter fields in specific types.
The `filterSchema` transform allows you to specify which schema elements to include or exclude in your mesh.
You can include or exclude entire queries and mutations, place restrictions on which types can appear in your calls or which fields can appear in specific types.

For example, you might want to exclude deprecated queries, mutations, and types from your schema so that your integration is not affected when these entities are removed.

## Installation

<PackageCmd packages={['@graphql-mesh/transform-filter-schema']} />

Expand Down Expand Up @@ -33,6 +38,8 @@ transforms:
- Query.*.!{id, name} # <-- This will remove args `id` and `name` from all fields in Query type
```

## Example

Let's assume you have the following schema:

```graphql
Expand Down
8 changes: 7 additions & 1 deletion website/src/pages/docs/transforms/naming-convention.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,18 @@ import { PackageCmd, Callout } from '@theguild/components'

# Naming Convention Transform

The `naming-convention` transform allows applying naming convention to GraphQL types and GraphQL fields easily.
The `naming-convention` transforms allow you to apply casing and other conventions to your response.

## Installation

<PackageCmd packages={['@graphql-mesh/transform-naming-convention']} />

## How to use?

<Callout>
In this example, enumValues fields are converted to uppercase, while fieldNames are converted to camel case to enforce consistency.
</Callout>

Add the following configuration to your Mesh config file:

```yaml filename=".meshrc.yaml"
Expand Down
6 changes: 5 additions & 1 deletion website/src/pages/docs/transforms/prefix.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@ import { PackageCmd, Callout } from '@theguild/components'

# Prefix Transform

The `prefix` transform allows you to prefix GraphQL types and GraphQL root operations (under `Query/Mutation`).
The `prefix` transforms allow you to add prefixes to existing GraphQL types and root operations (under `Query/Mutation`).
`prefix` is similar to [`rename`](/docs/transforms/rename) in that it allows you to modify names to avoid conflicts, simplify complicated names, and change the appearance of your query.
In contrast with `rename`, `prefix` is simpler and only allows you to append a `prefix` to the existing name.

You can use it to easily "namespace" APIs in your unified API and avoid conflicts.

## Installation

<PackageCmd packages={['@graphql-mesh/transform-prefix']} />

## How to use?
Expand Down
12 changes: 11 additions & 1 deletion website/src/pages/docs/transforms/rename.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ The `rename` transform allows you to rename:
- GraphQL fields
- GraphQL field arguments

The `rename` transform helps you avoid conflicting names, simplify complicated names and make queries look more like mutations.

`rename` elements can contain arrays of individual renaming operations, defined in separate renames objects.
Each of these objects must define the from and to values.

## Installation

<PackageCmd packages={['@graphql-mesh/transform-rename']} />

## How to use?
Expand Down Expand Up @@ -46,7 +53,10 @@ transforms:
`type` and `field` are mandatory to rename a field argument with `argument`.
</Callout>

or you can use regular expressions to rename multiple types, fields or both
### RegEx example

You can use RegEx flags to enable the use of regular expressions when renaming using this transform. This way you can rename multiple types, fields or both.
For example, you could use the key value pair field: api(.*) in the from object to rename any field of the corresponding type that begins with "api".

```yaml filename=".meshrc.yaml"
- rename:
Expand Down
13 changes: 9 additions & 4 deletions website/src/pages/docs/transforms/replace-field.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@ import { PackageCmd, Callout } from '@theguild/components'

# Replace Field

The `replace-field` transform allows you to replace configuration properties of a GraphQL field (source) with the ones of another field (target).
The `replace-field` transforms allow you to replace the configuration properties of one field with another.
This allows you to hoist field values from a subfield to its parent.

This is extremely useful when hoisting field values from one subfield to its parent. Still, it can be customized to completely replace and/or compose resolve functions with a great degree of customization.
Use this transform to clean up redundant looking queries or replace field types.
It can be customized to completely replace and/or compose resolve functions with a great degree of customization.

## Installation

<PackageCmd packages={['@graphql-mesh/transform-replace-field']} />

Expand Down Expand Up @@ -119,7 +123,7 @@ to:
field: books
```

To summarise, with the configuration above, we want the field `books` in type `Query` to be replaced from being of type `BooksApiResponse` to become type `[Book]`.
To summarize, with the configuration above, we want the field `books` in type `Query` to be replaced from being of type `BooksApiResponse` to become type `[Book]`.

Finally, since we no longer reference `BooksApiResponse` this becomes a loose type. So the transform will purge it from the GraphQL schema.

Expand All @@ -130,7 +134,8 @@ The transform always replaces the type of the source field with the one of the t

However, the transform also allows you to pass a scope property, which values can be `config` or `hoistValue`.

We could say that the scope property could also take a `type` value. Still, since it's the minimum requirement to replace the Type, this is considered the default scope and so it wouldn't make sense to pass it when you desire just this behaviour.
We could say that the scope property could also take a `type` value.
Still, since it's the minimum requirement to replace the Type, this is considered the default scope and so it wouldn't make sense to pass it when you desire just this behavior.

### `scope: config`

Expand Down
9 changes: 5 additions & 4 deletions website/src/pages/docs/transforms/transforms-introduction.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import { Callout } from '@theguild/components'

## Introduction to Transforms

GraphQL Mesh allows you to do schema transformations easily; you can use one of the built-in transforms or write your own.
GraphQL Mesh allows you to modify the schema easily, in order to control the contents of your GraphQL requests and responses;
you can use one of the built-in transforms or write your own.

Each transformer can manipulate the schema the way it needs and return the modified schema.

Expand Down Expand Up @@ -314,11 +315,11 @@ If you have use cases for which you would require to introduce either "bare" or
| Extend | βœ… | ❌ | [docs](/docs/transforms/extend) |
| Federation | ❌ | βœ… | [docs](/docs/transforms/federation) |
| Filter Schema | βœ… | βœ… | [docs](/docs/transforms/filter-schema) |
hoist
| hoist | | | [docs](/docs/transforms/hoist) |
| Naming Convention | βœ… | βœ… | [docs](/docs/transforms/naming-convention) |
| Prefix | βœ… | βœ… | [docs](/docs/transforms/prefix) |
prune
| prune | | | [docs](/docs/transforms/prune) |
| Rename | βœ… | βœ… | [docs](/docs/transforms/rename) |
| Replace Field | βœ… | ❌ | [docs](/docs/transforms/replace-field) |
| Resolvers Composition | βœ… | βœ… | [docs](/docs/transforms/resolvers-composition) |
type-merging
| type-merging | | | [docs](/docs/transforms/type-merging) |
Loading