CLI Overview
The graphql CLI validates and lints your GraphQL projects. Use it in CI/CD pipelines or during local development.
Install
Section titled “Install”# Homebrew (macOS/Linux)brew install trevor-scheer/graphql-analyzer/graphql-analyzer
# Or via install scriptcurl --proto '=https' --tlsv1.2 -LsSf https://raw.githubusercontent.com/trevor-scheer/graphql-analyzer/main/scripts/install.sh | shSee Installation for all methods.
Commands
Section titled “Commands”| Command | Description |
|---|---|
check |
Run validation + linting in a single pass (recommended) |
validate |
Run schema validation only |
lint |
Run lint rules only |
deprecations |
List all deprecated field usages across the project |
schema |
Schema-related commands (download, etc.) |
stats |
Display statistics about the GraphQL project |
fragments |
Analyze fragment usage across the project |
coverage |
Show schema field coverage by operations |
complexity |
Analyze query complexity for GraphQL operations |
mcp |
Start an MCP server for AI agent integration |
list-rules |
List all available lint rules |
explain |
Show details about a lint rule |
completions |
Generate shell completion scripts |
lsp |
Start the Language Server Protocol (LSP) server |
check is the recommended command — it’s more efficient than running validate and lint separately.
Quick usage
Section titled “Quick usage”# Run all checks (recommended)graphql check
# Validate onlygraphql validate
# Lint onlygraphql lint
# Watch modegraphql check --watch
# Download schema from a remote endpointgraphql schema download https://api.example.com/graphql -o schema.graphql
# View project statisticsgraphql stats
# Analyze query complexity with a thresholdgraphql complexity --threshold 100Global options
Section titled “Global options”| Option | Description |
|---|---|
-c, --config <FILE> |
Path to config file (auto-discovered by default) |
-p, --project <PROJECT> |
Project name for multi-project configs |
--color |
Force colored output even when not a TTY |
--no-color |
Disable colored output |
-q, --quiet |
Suppress all output except errors |
--no-progress |
Suppress progress spinners only |
-V, --version |
Print version and exit |
Each output-producing command supports -f, --format independently.
Output verbosity:
| Flag | Spinner | Results | Errors |
|---|---|---|---|
| (none) | Yes | Yes | Yes |
--no-progress |
No | Yes | Yes |
--quiet |
No | No | Yes |
Exit codes
Section titled “Exit codes”| Code | Meaning |
|---|---|
| 0 | Success — no errors |
| 1 | Validation or lint errors found |
| 2 | Configuration error (missing/invalid config) |
| 3 | Schema load error (introspection failed, etc.) |
| 4 | I/O error (file read/write failure) |
| 5 | Parse error (invalid GraphQL syntax) |
| 6 | Warning threshold exceeded (--max-warnings limit hit) |
graphql validatecase $? in 0) echo "All good!" ;; 1) echo "Fix your GraphQL errors" ;; 2) echo "Check your .graphqlrc configuration" ;; 3) echo "Schema could not be loaded" ;; *) echo "Unexpected error" ;;esacEnvironment variables
Section titled “Environment variables”| Variable | Description |
|---|---|
GRAPHQL_CONFIG |
Override config file path |
RUST_LOG |
Log level (error, warn, info, debug, trace) |
NO_COLOR |
Disable colored output |
CLICOLOR |
0 to disable, 1 to enable colors |
CLICOLOR_FORCE |
1 to force colors even without TTY |
Color priority (highest to lowest):
--color/--no-colorflagsNO_COLORenvironment variableCLICOLOR_FORCEenvironment variableCLICOLORenvironment variable- Auto-detect (colors enabled if stdout is a TTY)