GraphQL Schema Validator

Validate GraphQL SDL schemas — syntax, type references, and structural checks

Results will appear here after validation...

What is GraphQL Schema Validator?

GraphQL uses Schema Definition Language (SDL) to define the types, queries, mutations, and subscriptions in an API. A schema with syntax errors, duplicate types, or references to undefined types will fail at startup or cause runtime errors. This validator checks your schema SDL before you deploy.

How to Use

  1. Paste your GraphQL SDL schema into the editor.
  2. Click "Validate" to run structural and syntax checks.
  3. Review errors (blocks the schema) and warnings (potential issues).
  4. Fix errors and re-validate until no errors remain.
  5. Use "Load Sample" to see a valid schema example.

Why Use This Tool?

Detects duplicate type definitions (compile-time error in all GraphQL servers)
Finds references to undefined types in field definitions
Validates brace balance — catches unclosed type blocks
Warns about missing Query type (required by spec)
Identifies unused type definitions that may be dead code

Tips & Best Practices

  • Every GraphQL schema must have a "type Query" root — even if it's mostly mutations
  • Use ! for non-null fields: String! means the field will never be null
  • [Post!]! means the array is non-null AND each item in it is non-null
  • Input types (input keyword) are used for mutation arguments — they cannot have fields that resolve to interfaces or unions
  • Use schema linting in CI/CD (graphql-inspector, graphql-eslint) for production schemas

Frequently Asked Questions

What is the difference between a schema error and a warning?

Errors indicate problems that will prevent the schema from loading — duplicate type names, references to undefined types, unbalanced braces. Warnings indicate best-practice violations that won't prevent loading but may cause unexpected behavior, like a missing Query type or empty type bodies. Infos are advisory notices like unused types.

Does this validate queries against the schema?

No — this tool validates the schema definition itself (SDL), not GraphQL queries against a schema. To validate a query against a schema, you need a full GraphQL executor like graphql-js. Check the "GraphQL Builder" tool for query construction.

Can I validate schema fragments (partial SDL)?

Yes, but undefined type references will be flagged as errors because the validator doesn't know which types are defined in other files. If you're validating a partial schema, the "unknown type" errors for imported types can be ignored — focus only on syntax and duplicate errors.

Related Tools