Skip to content

Output Formats

All CLI commands support four output formats via the --format flag.

Colorized, human-readable output with source context:

✗ 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

Machine-readable JSON for CI/CD pipelines and custom tooling:

Terminal window
graphql check --format json

The check command emits an object with per-file errors and warnings arrays and a unified stats block:

{
"success": false,
"schema_loaded": true,
"files": [
{
"file": "src/queries.graphql",
"errors": [
{
"message": "Cannot query field \"invalidField\" on type \"User\"",
"severity": "error",
"source": "validation",
"rule": null,
"location": {
"start": { "line": 5, "column": 3 },
"end": { "line": 5, "column": 15 }
}
}
],
"warnings": []
}
],
"stats": {
"total_files": 1,
"total_errors": 1,
"total_warnings": 0,
"validation_errors": 1,
"lint_errors": 0
}
}

GitHub Actions annotation format — errors and warnings appear as inline annotations on pull requests:

Terminal window
graphql validate --format github
::error file=src/queries.graphql,line=5,col=3,endLine=5,endColumn=15::Cannot query field "invalidField" on type "User"

See CI/CD Integration for a full GitHub Actions workflow.

SARIF (Static Analysis Results Interchange Format) for GitHub code scanning integration. Enables rich PR annotations and populates the Security tab:

Terminal window
graphql check --format sarif > results.sarif
{
"$schema": "https://raw.githubusercontent.com/oasis-tcs/sarif-spec/main/sarif-2.1/schema/sarif-schema-2.1.0.json",
"version": "2.1.0",
"runs": [
{
"tool": {
"driver": {
"name": "graphql-analyzer",
"rules": [{ "id": "noAnonymousOperations", "shortDescription": { "text": "..." } }]
}
},
"results": [
{
"ruleId": "noAnonymousOperations",
"level": "error",
"message": { "text": "All operations must be named" },
"locations": [
{
"physicalLocation": {
"artifactLocation": { "uri": "src/queries.graphql" },
"region": { "startLine": 1, "startColumn": 1 }
}
}
]
}
]
}
]
}

Upload to GitHub code scanning:

- run: graphql check -f sarif > results.sarif
- uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: results.sarif

See CI/CD Integration for a full workflow example.