GraphQL
GraphQL Mesh v0 documentation (superseded by v1): GraphQL Mesh is a schema-stitching tool that enables loading remote GraphQL schemas, fetched from a CDN or registry, and using them with schema-stitching based on graphql-tools.

This handler allows you to load remote GraphQL schemas and use them with schema-stitching based on
graphql-tools.
To get started, install the handler library:
Now, you can use it directly in your Mesh config file:
Headers
Read about configuration and examples.
Fetching SDL or introspection from CDN or any other schema registry tool
Let’s say the introspection disabled in your production environment of your GraphQL source, and you want to provide your SDL or introspection seperately;
In this case, CLI’s
buildcommand won’t save the introspection in the artifacts, so your Mesh won’t start ifsourceURL is down.
Hive Integration
If you use GraphQL Hive to manage your GraphQL APIs as a schema registry, you can use the following configuration to fetch your schema from Hive:
Local Schemas
We recommend providing local schema by using the additionalTypeDefs and additionalResolvers
configuration options.
However, it is also possible to use a local GraphQL Schema instance as a GraphQL Mesh source, as showcased below:
Fetch Strategies and Multiple HTTP endpoints for the same source
If you want to have an advanced fetch strategy for the GraphQL source such as retrying twice or timeout in 30 seconds etc. Also, you can have different HTTP endpoints for a single source, and you can configure Mesh to get a better execution flow.
For example, you can make a request to both endpoints and return the fastest response with race
strategy.
All fetch strategies can be combined to create the ultimate execution flow:
retry
The retry mechanism allow you to specify the retry attempts for a single GraphQL endpoint/source.
The retry flow will execute in both conditions: a network error, or due to a runtime error.
timeout
The timeout mechanism allow you to specify the timeout for a given GraphQL endpoint.
fallback
The fallback mechanism allow you to specify use more than one GraphQL endpoint, for the same
source.
This is helpful if you have a fallback endpoint for the same GraphQL API.
race
The race mechanism allow you to specify use more than one GraphQL endpoint, for the same source,
and race on every execution.
If you have different places that service is deployed, this is useful to get the fastest response by racing them.
Config API Reference
endpoint(type:String, required) - A url or file path to your remote GraphQL endpoint. If you provide a path to a code file(js or ts), other options will be ignored and the schema exported from the file will be used directly.schemaHeaders(type:Any) - JSON object representing the Headers to add to the runtime of the API calls only for schema introspectionoperationHeaders(type:JSON) - JSON object representing the Headers to add to the runtime of the API calls only for operation during runtimeuseGETForQueries(type:Boolean) - Use HTTP GET for Query operationsmethod(type:String (GET | POST)) - HTTP method used for GraphQL operationscredentials(type:String (omit | include)) - Request Credentials if your environment supports it. See more
@default “same-origin”
webSocketImpl(type:String) - Path to a custom W3 Compatible WebSocket Implementationsource(type:String) - Path to the introspection You can separately give schema introspection or SDLsubscriptionsProtocol(type:String (SSE | WS | LEGACY_WS)) - SSE - Server Sent Events WS - New graphql-ws LEGACY_WS - Legacy subscriptions-transport-wssubscriptionsEndpoint(type:String) - URL to your endpoint serving all subscription queries for this sourceretry(type:Int) - Retry attempts if failstimeout(type:Int) - Timeout in millisecondsbatch(type:Boolean) - Enable/Disable automatic query batchingconnectionParams(type:JSON) - JSON object representing theconnectionParamsfrom a WebSocket connection to add to the runtime of the API calls only for operation during runtime. More information about the WebSocketconnectionParams:- When using
subscriptionsProtocol=WS(graphql-ws): https://github.com/enisdenjo/graphql-ws/blob/master/docs/interfaces/client.ClientOptions.md#connectionparams - When using
subscriptionsProtocol=LEGACY_WS(subscriptions-transport-ws): https://github.com/apollographql/subscriptions-transport-ws/blob/51270cc7dbaf09c7b9aa67368f1de58148c7d334/README.md#subscriptionclient
- When using
or
source(type:Any, required) - A file path to your GraphQL Schema If you provide a path to a code file(js or ts), other options will be ignored and the schema exported from the file will be used directly.