---
name: graphql-schema-validator
description: "A pre-merge validation report for a GraphQL schema: each rule in your chosen ruleset checked and every violation listed with line number and severity, plus your sample queries verified against the schema so they fail here rather than in production. Use when a GraphQL schema and the queries clients send need checking against lint rules and the spec before a merge, with every violation listed by line and severity. Do not use for diagnosing one failing error from server logs, or a broad design audit with recommendations. Related topics: coding, graphql."
---

# GraphQL Schema Validator

A pre-merge validation report for a GraphQL schema: each rule in your chosen ruleset checked and every violation listed with line number and severity, plus your sample queries verified against the schema so they fail here rather than in production.

## When to use

Use this skill when a GraphQL schema and the queries clients send need checking against lint rules and the spec before a merge, with every violation listed by line and severity. Do not use it for diagnosing one failing error from server logs, or a broad design audit with recommendations.

## Workflow

1. Ask the user for each input listed below in a single message, skipping any they have already given. Where options are listed, offer them, but accept other answers too.
2. Check spec validity first: defined types, no duplicates, no input non-null cycles, directives on declared locations, interfaces fully implemented.
3. Apply each selected rule and record a finding with line number, rule, and severity per violation.
4. Validate every sample query against the schema for unknown fields, argument errors, bad selections, wrong fragment types, and deprecated field use.
5. Filter by the severity threshold and sort errors first then by line, adding a one-line fix per finding when fixes are on.
6. State the pass or fail verdict with counts per severity.

## Inputs

- **Schema SDL** (longer free text)
- **Sample queries** (longer free text)
- **Validation ruleset** (choose any: Type consistency, Field existence, Directive usage, Deprecation warnings, Naming conventions, Required descriptions, Input type cycles)
- **Severity threshold** (choose one: All, Warnings only, Errors only)
- **Output format** (choose one: Markdown, JSON, Plain text)
- **Include suggested fixes** (choose one: Yes, No)

## Output

A report in the chosen format: a verdict line with counts, then a findings table (line, rule, severity, message, fix when enabled) for the schema followed by one per sample query.

## Prompt template

Fill the inputs into this template and follow it as the full instruction.

### GraphQL Schema Validator

Validate my GraphQL schema against a ruleset and check my sample queries against it.

#### Details
- Schema SDL: {{Schema SDL}}
- Sample queries: {{Sample queries}}
- Validation ruleset: {{Validation ruleset}}
- Severity threshold: {{Severity threshold}}
- Output format: {{Output format}}
- Include suggested fixes: {{Include suggested fixes}}

Check the schema for spec validity before any style rule: every referenced type defined, no duplicate fields or types, input types free of non-null cycles, directives used only on the locations they declare, interfaces fully implemented. Then apply each selected rule and record a finding per violation with the line number, the rule, and a severity (error for anything that fails schema load or a client query, warning for everything else). Validate each sample query against the schema: unknown fields, missing required arguments, wrong argument types, selections on scalars, fragments on the wrong type, and use of deprecated fields. Filter the findings by the severity threshold and sort errors first, then by line. When fixes are on, give a one-line fix per finding with the corrected snippet where it is short. End with a pass or fail verdict and the counts per severity.

## Pitfalls

- Reporting style violations before spec errors, so a schema that cannot load still looks mostly green.
- Marking deprecated field use in a query as an error when it is a warning the client may knowingly accept.
- Skipping the sample queries because the schema passed, when the queries are where production breaks.
