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.

CommandDescription
checkRun validation + linting in a single pass (recommended)
validateRun schema validation only
lintRun lint rules only
deprecationsList all deprecated field usages across the project
schemaSchema-related commands (download, etc.)
statsDisplay statistics about the GraphQL project
fragmentsAnalyze fragment usage across the project
coverageShow schema field coverage by operations
complexityAnalyze query complexity for GraphQL operations
mcpStart an MCP server for AI agent integration
list-rulesList all available lint rules
explainShow details about a lint rule
completionsGenerate shell completion scripts
lspStart 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
OptionDescription
-c, --config <FILE>Path to config file (auto-discovered by default)
-p, --project <PROJECT>Project name for multi-project configs
--colorForce colored output even when not a TTY
--no-colorDisable colored output
-q, --quietSuppress all output except errors
--no-progressSuppress progress spinners only
-V, --versionPrint version and exit

Each output-producing command supports -f, --format independently.

Output verbosity:

FlagSpinnerResultsErrors
(none)YesYesYes
--no-progressNoYesYes
--quietNoNoYes
CodeMeaning
0Success — no errors
1Validation or lint errors found
2Configuration error (missing/invalid config)
3Schema load error (introspection failed, etc.)
4I/O error (file read/write failure)
5Parse error (invalid GraphQL syntax)
6Warning 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
VariableDescription
GRAPHQL_CONFIGOverride config file path
RUST_LOGLog level (error, warn, info, debug, trace)
NO_COLORDisable colored output
CLICOLOR0 to disable, 1 to enable colors
CLICOLOR_FORCE1 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)