CI/CD Integration
GitHub Actions
Section titled “GitHub Actions”The shortest path is the GitHub Action:
name: GraphQLon: [pull_request]jobs: check: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: trevor-scheer/graphql-analyzer-action@v1It installs the released CLI, runs graphql check, emits inline PR annotations, and supports SARIF + an optional summary comment. See the GitHub Action page for the full reference.
Without the action
Section titled “Without the action”If you’d rather call the CLI directly — for example, on self-hosted runners or to share install logic across many steps — the binary install pattern still works:
name: GraphQL Validationon: [pull_request]
jobs: graphql: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Install GraphQL CLI run: | curl --proto '=https' --tlsv1.2 -LsSf \ https://raw.githubusercontent.com/trevor-scheer/graphql-analyzer/main/scripts/install.sh | sh - name: Check GraphQL run: graphql check --format github--format github turns errors into pull request annotations.
GitHub Code Scanning (SARIF)
Section titled “GitHub Code Scanning (SARIF)”- name: Check GraphQL (SARIF) run: graphql check --format sarif > results.sarif- name: Upload SARIF uses: github/codeql-action/upload-sarif@v3 with: sarif_file: results.sarifTo run validation and linting as separate steps:
- name: Validate GraphQL run: graphql validate --format github- name: Lint GraphQL run: graphql lint --format githubGitLab CI
Section titled “GitLab CI”graphql: script: - curl --proto '=https' --tlsv1.2 -LsSf https://raw.githubusercontent.com/trevor-scheer/graphql-analyzer/main/scripts/install.sh | sh - graphql check --format jsonGeneric CI
Section titled “Generic CI”# Installcurl -LsSf https://raw.githubusercontent.com/trevor-scheer/graphql-analyzer/main/scripts/install.sh | sh
# Run checksgraphql check --format json > results.json
# Check exit codeif [ $? -ne 0 ]; then echo "GraphQL validation failed" exit 1fiPre-commit hooks
Section titled “Pre-commit hooks”Using husky:
{ "husky": { "hooks": { "pre-commit": "graphql check" } }}Enabling expensive rules in CI
Section titled “Enabling expensive rules in CI”Some lint rules (like noUnusedFields) are too expensive for real-time editor feedback but work well in CI. Enable them via CLI-specific config overrides in .graphqlrc.yaml:
extensions: lint: extends: recommended cli: lint: rules: noUnusedFields: error noUnusedFragments: errorThe extensions.cli.lint.rules block applies only when running the CLI, so the LSP and editor stays fast.
Enforcing zero warnings in CI
Section titled “Enforcing zero warnings in CI”Use --max-warnings 0 to treat any warning as a failure:
graphql check --max-warnings 0This returns exit code 6 if any warnings are found, making CI strict about warnings without promoting them all to errors in the config.