Package Exports
- graphql-config
- graphql-config/lib/GraphQLProjectConfig
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (graphql-config) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
graphql-config
The README reflects new graphql-config protocol. Old graphql-config-parser documentation can be found here
The easiest way to configure your development environment with your GraphQL schema (supported by most tools, editors & IDEs)
Supported by...
Editors
- js-graphql-intellij-plugin - GraphQL language support for IntelliJ IDEA and WebStorm, including Relay.QL tagged templates in JavaScript and TypeScript (pending)
- atom-language-graphql - GraphQL support for Atom text editor (pending)
Tools
- babel-plugin-react-relay - Babel compile step to process your
Relay.QLqueries (pending) - babel-plugin-transform-relay-hot - Wrapper under BabelRelayPlugin with hot reload (pending)
- eslint-plugin-graphql - An ESLint plugin that checks tagged template strings against a GraphQL schema (pending)
- webpack-plugin-graphql-schema-hot - Webpack plugin which tracks changes in your schema and generates its introspection in
jsonandtxtformats (pending)
Did we forget a tool/editor? Please add it here.
Usage
You can either configure your GraphQL endpoint via a configuration file .graphqlconfig
(or .graphqlconfig.yaml) which should be put into the root of your project
Note: This requires Node 5 installed or higher
Simplest use case
The simplest config specifies only schemaPath which is path to the file with introspection
results or corresponding SDL document
{
"schemaPath": "schema.graphql"
}Specifying include/exclude files
You can specify which files to include/exclude using the corresponding options:
{
"schemaPath": "schema.graphql",
"include": ["*.graphql"],
"exclude": ["temp/**"]
}Note: exclude and include fields are globs that should match filename. So, just
temportemp/won't match all files inside the directory. That's why the example usestemp/**
Specifying endpoint info
You may specify your endpoints info in .graphqlconfig. The simplest case:
{
"schemaPath": "schema.graphql",
"extensions": {
"endpoint": "https://example.com/graphql"
}
}In case you need provide addition information for example headers to authenticate your GraphQL endpoint or a endpoint for subscription you can use expanded version:
{
"schemaPath": "schema.graphql",
"extensions": {
"endpoint": {
"url": "https://example.com/graphql",
"headers": {
"Authorization": "Bearer ${env:AUTH_TOKEN_ENV}"
},
"subscription": {
"url": "ws://example.com/graphql",
"connectionParams": {
"Token": "${env:YOUR_APP_TOKEN}"
}
}
}
}
}Note: do not save secure information in .graphqlconfig file. Use Environment variables for that like in the example above.
In case if you have multiple endpoints use the following syntax:
{
"schemaPath": "schema.graphql",
"extensions": {
"endpoint": {
"prod": {
"url": "https://your-app.com/graphql",
"subscription": {
"url": "wss://subscriptions.graph.cool/v1/instagram"
}
},
"dev": {
"url": "http://localhost:3000/graphql",
"subscription": {
"url": "ws://localhost:3001"
}
}
}
}
}Multi-project configuration
TBD
Refer to specification use-cases for details
How it works
This project aims to be provide a unifying configuration file format to configure your GraphQL schema in your development environment.
Additional to the format specification, it provides the graphql-config library, which is used by all supported tools and editor plugins. The library reads your provided configuration and passes the actual GraphQL schema along to the tool which called it.
graphql-config API

WIP: More examples are coming soon
getGraphQLProjectConfig
NOTE: if you work with files (e.g. editor plugin, linter, etc) use GraphQLConfig class and
getConfigForFilemethod to get instance of the correctGraphQLProjectConfig
getGraphQLProjectConfig should be used by tools that do not work on per-file basis
import { getGraphQLProjectConfig } from 'graphql-config'
const config = getGraphQLProjectConfig('./optionalProjectDir', 'optionalProjectName')
const schema = config.getSchema()
// use schema for your tool/plugingetGraphQLConfig
getGraphQLConfig should be used by tools that work on per-file basis (editor plugins,
linters, etc.)
import { getGraphQLConfig } from 'graphql-config'
const config = getGraphQLConfig('./optionalProjectDir')
const schema = config.getConfigForFile(filename).getSchema()
// use schema for your tool/pluginHelp & Community 
Join our Slack community if you run into issues or have questions. We love talking to you!
