graphql-inspector validate: Check Operations vs Schema
graphql-inspector validate checks that your GraphQL operation documents are valid against the schema and exits non-zero when any operation is invalid.
Client operations drift from the schema over time. validate catches queries that reference removed fields or wrong argument types before they ship.
What it does
The validate command takes a glob of operation documents and a schema pointer, then validates every query, mutation, subscription, and fragment against the schema, reporting errors and (optionally) uses of deprecated fields.
Common usage
graphql-inspector validate "src/**/*.graphql" schema.graphql
# also flag operations that use deprecated fields
graphql-inspector validate "src/**/*.graphql" schema.graphql --deprecatedOptions
| Flag | What it does |
|---|---|
| <documents> <schema> | Operations glob then schema pointer |
| -d, --deprecated | Fail when operations use deprecated fields |
| --noStrictFragments | Do not error on unused fragments |
| --maxDepth <n> | Fail when an operation exceeds a query depth |
| --apollo | Support Apollo-style client directives |
| --headers <k=v> | Headers when loading a remote schema |
In CI
Validate the operations in your repo against the committed schema on every PR so a schema change that invalidates a query fails the client build. Add --deprecated to enforce a migration deadline once fields are marked deprecated.
Common errors in CI
Invalid operations print Cannot query field "X" on type "Y" or Unknown argument "z" on field ..., and the command exits non-zero. With --deprecated, uses of deprecated fields are reported as errors. "Couldn't find any GraphQL documents" means the operations glob matched nothing (check quoting so the shell does not expand it).