Specifying Schema
The simplest config specifies only schema
which points to the source of GraphQL schema.
schema: ./schema.graphql
GraphQL Config can start with a single schema and grow from there.
Multiple Files
GraphQL Config can also assemble multiple modularized schemas into a single GraphQL schema object.
You can specify a list of files:
schema:
- ./foo.graphql
- ./bar.graphql
- ./baz.graphql
Alternatively, you can use a glob pattern to find and include pieces of schema:
schema: ./*.graphql
GraphQL Config looks for those files, reads the files and merges them to produce a GraphQL schema object.
Introspection Result
A very common way to describe a GraphQL schema is to run an introspection query on it and save the resulting output as a JSON file. GraphQL Config can also read these files into schema objects.
schema: ./schema.json
Note that JSON introspection results are parsed for both file validity and for schema validity; if either check fails, an error message will be passed back to the caller.
Endpoint
In case you want to access a running GraphQL server via its endpoint, you can pass its address into the configuration file.
schema: http://localhost:4000/graphql
Environment Variables
It is possible to load definitions from environment variables, with or without fallback values.
schema: ${SCHEMA_FILE:./schema.json}
If you want to define a fallback endpoint you may wrap your value with quotation marks.
schema: ${SCHEMA_ENDPOINT:"http://localhost:4000/graphql"}
Passing Headers
If you need to pass headers in the schema request you can do it this way:
schema:
- http://localhost:4000/graphql:
headers:
Authorization: Token