Skip to content

CLI Overview

The graphql CLI validates and lints your GraphQL projects. Use it in CI/CD pipelines or during local development.

Terminal window
# Homebrew (macOS/Linux)
brew install trevor-scheer/graphql-analyzer/graphql-analyzer
# Or via install script
curl --proto '=https' --tlsv1.2 -LsSf https://raw.githubusercontent.com/trevor-scheer/graphql-analyzer/main/scripts/install.sh | sh

See Installation for all methods.

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.

Terminal window
# Run all checks (recommended)
graphql check
# Validate only
graphql validate
# Lint only
graphql lint
# Watch mode
graphql check --watch
# Download schema from a remote endpoint
graphql schema download https://api.example.com/graphql -o schema.graphql
# View project statistics
graphql stats
# Analyze query complexity with a threshold
graphql complexity --threshold 100
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
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)
Terminal window
graphql validate
case $? 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" ;;
esac
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):

  1. --color / --no-color flags
  2. NO_COLOR environment variable
  3. CLICOLOR_FORCE environment variable
  4. CLICOLOR environment variable
  5. Auto-detect (colors enabled if stdout is a TTY)