Edit in GitHubLog an issue

GraphQL handlers

This handler allows you to load remote GraphQL schemas and use them with schema-stitching, based on graphql-tools. To get started, use the handler in your Mesh config file:

Copied to your clipboard
{
"sources": [
{
"name": "MyGraphQLApi",
"handler": {
"graphql": {
"endpoint": "https://my-service-url/graphql"
}
}
}
]
}

GraphQL handlers can also use local sources, see Reference local file handlers for more information.

Headers from context

Copied to your clipboard
{
"sources": [
{
"name": "MyGraphQLApi",
"handler": {
"graphql": {
"endpoint": "https://my-service-url/graphql",
"operationHeaders": {
"Authorization": "Bearer {context.headers['x-my-api-token']}"
// Do not use capital letters in header names.
}
}
}
}
]
}

Fetching SDL or introspection from CDN or somewhere

Imagine that introspection is disabled in the production environment of your GraphQL source, and you want to provide your SDL or introspection separately:

Copied to your clipboard
{
"sources": [
{
"name": "MyGraphQLApi",
"handler": {
"graphql": {
"endpoint": "https://api.github.com/graphql",
"operationHeaders": {
"Authorization": "Bearer {context.headers['GITHUB_TOKEN']}"
}
}
}
}
]
}

In this case, CLI's build command won't save the introspection in the artifacts, so your Mesh won't start if the source URL is down.

Local Schemas

We recommend providing local schema by using the additionalTypeDefs and additionalResolvers configuration options.

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 introspection
  • operationHeaders (type: JSON) - JSON object representing the Headers to add to the runtime of the API calls only for operation during runtime
  • useGETForQueries (type: Boolean) - Use HTTP GET for Query operations
  • method (type: String (GET | POST)) - HTTP method used for GraphQL operations
  • Privacy
  • Terms of Use
  • Do not sell or share my personal information
  • AdChoices
Copyright © 2023 Adobe. All rights reserved.