Skip to content

Configuration File

GraphQL Analyzer uses the standard .graphqlrc configuration format, compatible with tools like GraphQL Code Generator and GraphQL ESLint.

YAML, JSON, and TOML are supported. JavaScript/TypeScript configs (graphql.config.js, graphql.config.ts) are not supported.

The tool searches for these files in order, walking up the directory tree from your project root:

  1. .graphqlrc.yml / .graphqlrc.yaml
  2. .graphqlrc.json
  3. .graphqlrc.toml
  4. .graphqlrc (YAML or JSON, auto-detected)
  5. graphql.config.yml / graphql.config.yaml
  6. graphql.config.json
  7. graphql.config.toml
  8. package.json (with a "graphql" key — lowest priority fallback)

You can also specify a config file explicitly:

Terminal window
graphql --config path/to/.graphqlrc.yml validate
.graphqlrc.yml
schema: "schema.graphql"
documents: "src/**/*.{graphql,ts,tsx}"
FieldRequiredDescription
schemaYesSchema source (file, glob, or URL)
documentsNoDocument file patterns
includeNoFile patterns that scope which files belong to this project
excludeNoFile patterns to exclude from this project
schema: "schema.graphql"
documents: "src/**/*.{graphql,ts,tsx}"
extensions:
graphql-analyzer:
lint:
extends: recommended
rules:
noDeprecated: warn

See Linting Configuration for details.

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}

See Multi-Project Workspaces for details.

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"

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.

Terminal window
node -e "import('./graphql.config.js').then(c => console.log(JSON.stringify(c.default ?? c, null, 2)))" > .graphqlrc.json

The 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:

Terminal window
node -e "console.log(require('js-yaml').dump(require('./.graphqlrc.json')))" > .graphqlrc.yml && rm .graphqlrc.json

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:

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.yml or .graphqlrc.json to disk before invoking GraphQL Analyzer; treat the generated file as a build artifact.

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 of VAR; fails with an error if the variable is unset
  • ${VAR:default} — replaced with the value of VAR, or default if 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.

VariableDescription
RUST_LOGSet log level for debugging