Skip to content

Documents

The documents field tells GraphQL Analyzer where to find your GraphQL operations and fragments.

# Pure GraphQL files
documents: "src/**/*.graphql"
# Multiple file types
documents: "src/**/*.{graphql,ts,tsx,vue,svelte,astro}"
documents:
- "src/**/*.graphql"
- "src/**/*.gql"
- "src/**/*.tsx"
- "src/**/*.ts"
- "src/**/*.jsx"
- "src/**/*.js"
- "src/**/*.vue"
- "src/**/*.svelte"
- "src/**/*.astro"

Use ! prefix to exclude patterns:

documents:
- "src/**/*.{ts,tsx}"
- "!src/**/*.test.ts"
- "!src/**/*.spec.ts"

When you include .ts, .tsx, .js, .jsx, .vue, .svelte, or .astro files, GraphQL Analyzer automatically extracts GraphQL from tagged template literals:

import { gql } from "graphql-tag";
const query = gql`
query GetUser($id: ID!) {
user(id: $id) {
id
name
}
}
`;

For Vue, Svelte, and Astro files, the analyzer first extracts <script> blocks (or Astro frontmatter), then runs the same extraction pipeline. See Embedded GraphQL for details and examples.

The extractConfig schema mirrors @graphql-tools/graphql-tag-pluck so users coming from @graphql-eslint (or any pluck-based pipeline) can paste their pluck config directly. The pluckConfig key is accepted as an alias for extractConfig; setting both on the same project is a configuration error.

By default, the tool recognizes gql and graphql from common GraphQL libraries. You can customize this:

documents: "src/**/*.tsx"
extensions:
graphql-analyzer:
extractConfig:
modules:
- "graphql-tag"
- { name: "@apollo/client", identifier: "gql" }
- { name: "custom-gql", identifier: "query" }
globalGqlIdentifierName: ["gql", "graphql", "query"]
Option Default Description
modules graphql-tag, graphql-tag.macro, @apollo/client, @apollo/client/core, gatsby, react-relay, react-relay/hooks, relay-runtime, babel-plugin-relay/macro, graphql.macro, urql, @urql/core, @urql/preact, @urql/svelte, @urql/vue (with appropriate identifiers) Modules whose imports of GraphQL tags are recognized. Each entry is either a string (shorthand for { name }) or { name, identifier? }. When a module specifies an identifier, only the named import matching that identifier is recognized as a GraphQL tag.
gqlMagicComment "graphql" Magic comment for /* graphql */ \…`` style extraction.
globalGqlIdentifierName ["gql", "graphql"] Identifiers recognized as GraphQL tags without an import. Pass false (or []) to require an import for every tag.
gqlVueBlock (unset) Optional Vue SFC block name (e.g. "graphql") for raw GraphQL inside custom blocks.
skipIndent false Normalize indentation by stripping common leading whitespace from extracted GraphQL.