Configuration File
GraphQL Analyzer uses the standard .graphqlrc configuration format, compatible with tools like GraphQL Code Generator and GraphQL ESLint.
File format
Section titled “File format”YAML, JSON, and TOML are supported. JavaScript/TypeScript configs (graphql.config.js, graphql.config.ts) are not supported.
File discovery
Section titled “File discovery”The tool searches for these files in order, walking up the directory tree from your project root:
.graphqlrc.yml/.graphqlrc.yaml.graphqlrc.json.graphqlrc.toml.graphqlrc(YAML or JSON, auto-detected)graphql.config.yml/graphql.config.yamlgraphql.config.jsongraphql.config.tomlpackage.json(with a"graphql"key — lowest priority fallback)
You can also specify a config file explicitly:
graphql --config path/to/.graphqlrc.yml validateBasic configuration
Section titled “Basic configuration”schema: "schema.graphql"documents: "src/**/*.{graphql,ts,tsx}"schema = "schema.graphql"documents = "src/**/*.{graphql,ts,tsx}"{ "schema": "schema.graphql", "documents": "src/**/*.{graphql,ts,tsx}"}| Field | Required | Description |
|---|---|---|
schema | Yes | Schema source (file, glob, or URL) |
documents | No | Document file patterns |
include | No | File patterns that scope which files belong to this project |
exclude | No | File patterns to exclude from this project |
Adding linting
Section titled “Adding linting”schema: "schema.graphql"documents: "src/**/*.{graphql,ts,tsx}"
extensions: graphql-analyzer: lint: extends: recommended rules: noDeprecated: warnschema = "schema.graphql"documents = "src/**/*.{graphql,ts,tsx}"
[extensions.graphql-analyzer.lint]extends = "recommended"
[extensions.graphql-analyzer.lint.rules]noDeprecated = "warn"See Linting Configuration for details.
Multi-project setup
Section titled “Multi-project setup”For monorepos or projects with multiple GraphQL schemas:
projects: api: schema: api/schema.graphql documents: api/**/*.graphql client: schema: client/schema.graphql documents: client/**/*.{graphql,tsx}[projects.api]schema = "api/schema.graphql"documents = "api/**/*.graphql"
[projects.client]schema = "client/schema.graphql"documents = "client/**/*.{graphql,tsx}"See Multi-Project Workspaces for details.
Migrating from JavaScript config
Section titled “Migrating from JavaScript config”If you have a graphql.config.js or graphql.config.ts, convert it to YAML, JSON, or TOML.
For configs that are already plain objects, the translation is mechanical:
// graphql.config.js (NOT SUPPORTED)module.exports = { schema: "schema.graphql", documents: "src/**/*.graphql",};# .graphqlrc.yml (equivalent)schema: "schema.graphql"documents: "src/**/*.graphql"One-liner conversion
Section titled “One-liner conversion”If your config is a static object (or evaluates to one), dump it to JSON with a single command. .graphqlrc.json is supported directly — no further conversion required.
node -e "import('./graphql.config.js').then(c => console.log(JSON.stringify(c.default ?? c, null, 2)))" > .graphqlrc.jsonThe dynamic import() returns a promise resolving to the namespace object, which .then(c => …) unwraps. c.default ?? c picks the ESM default export when present, otherwise falls back to the CJS exports object — so the same command handles both module.exports = … and export default ….
For TypeScript configs, point at graphql.config.ts instead. Modern Node strips type annotations natively (Node 22.6+ with --experimental-strip-types, or Node 23.6+ where it’s on by default), so no separate runner like tsx is needed.
If you’d prefer YAML, pipe the JSON through any YAML converter — for example, with js-yaml installed:
node -e "console.log(require('js-yaml').dump(require('./.graphqlrc.json')))" > .graphqlrc.yml && rm .graphqlrc.jsonWhat won’t carry over
Section titled “What won’t carry over”graphql.config.js is loaded by cosmiconfig, which evaluates the JavaScript at load time. That means JS configs can express things a static YAML/JSON/TOML file cannot. GraphQL Analyzer does not support any of the following:
Workarounds for dynamic needs
Section titled “Workarounds for dynamic needs”Most real-world dynamic configs fall into one of two buckets, and both have static equivalents:
- Secrets, tokens, and per-environment URLs → use environment variable interpolation.
${API_TOKEN}and${TENANT_ID:default-tenant}cover the common cases without any JavaScript. - Anything else dynamic (computed schemas, conditional projects, generated globs) → generate the config file as a build step. Have your existing JavaScript write a
.graphqlrc.ymlor.graphqlrc.jsonto disk before invoking GraphQL Analyzer; treat the generated file as a build artifact.
Environment variable interpolation
Section titled “Environment variable interpolation”Config values support ${VAR} and ${VAR:default} substitution. This is useful for keeping secrets like API tokens out of your config file:
schema: url: https://api.example.com/graphql headers: Authorization: Bearer ${API_TOKEN} X-Tenant: ${TENANT_ID:default-tenant}${VAR}— replaced with the value ofVAR; fails with an error if the variable is unset${VAR:default}— replaced with the value ofVAR, ordefaultif the variable is unset
Interpolation is applied to all string values before the config is parsed, so it works in any field — URLs, headers, file paths, etc.
Environment variables
Section titled “Environment variables”| Variable | Description |
|---|---|
RUST_LOG | Set log level for debugging |