Edit in GitHubLog an issue

GraphQL handlers

This handler allows you to load remote GraphQL schemas as part of your mesh. The GraphQL handler uses the following format:

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://your-service/graphql",
"operationHeaders": {
"Authorization": "Bearer {context.headers['x-my-api-token']}"
// Do not use capital letters in header names.
}
}
}
}
]
}

Fetching SDL or introspection from CDN

Consider a scenario where 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://your-service/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 a local schema by using the additionalTypeDefs and additionalResolvers configuration options.

Config API reference

  • endpoint (type: String, required) - URL or file path for your remote GraphQL endpoint
    • Local file types must be .js or .ts.
  • schemaHeaders (type: Any) - JSON object for adding headers to API calls for runtime schema introspection
  • operationHeaders (type: JSON) - JSON object for adding headers to API calls for runtime operation execution
  • useGETForQueries (type: Boolean) - An HTTP GET method for query operations
  • method (type: String (GET | POST)) - An HTTP method for GraphQL operations
  • Privacy
  • Terms of Use
  • Do not sell or share my personal information
  • AdChoices
Copyright © 2024 Adobe. All rights reserved.