validate
The validate command runs Apollo compiler validation on your GraphQL documents against your schema.
graphql validate [OPTIONS]Options
Section titled “Options”| Option | Description |
|---|---|
-f, --format <FORMAT> | Output format: human (default), json, github, sarif |
-w, --watch | Watch for file changes and re-validate |
--syntax-only | Skip schema validation, only check syntax |
Examples
Section titled “Examples”# Basic validation (requires schema)graphql validate
# JSON output for CIgraphql validate --format json
# Watch mode for developmentgraphql validate --watch
# Only check syntax, skip schema validationgraphql validate --syntax-only
# Specific project in a multi-project configgraphql --project backend validateBehavior
Section titled “Behavior”By default, validate requires a schema and will fail with exit code 2 if:
- No schema files match the configured patterns
- No document files match the configured patterns
Use --syntax-only to skip schema validation when you only need to check GraphQL syntax.
Example output
Section titled “Example output”✗ Validation error in src/queries.graphql:5:3 Cannot query field "invalidField" on type "User"
3 | user(id: $id) { 4 | id 5 | invalidField | ^^^^^^^^^^^^ 6 | }
✓ 12 files validated, 1 error found