GraphQL Validator

Validate GraphQL queries and schemas

Paste your GraphQL query or schema here...
Loading editor...

GraphQL Validator — Validate GraphQL Queries Against a Schema

Understanding the Basics

GraphQL validation is a two-phase process: syntactic parsing (is the document grammatically valid GraphQL?) and semantic validation (does the document conform to the rules of the target schema?). The GraphQL specification defines 26 validation rules in Section 5, covering query structure, field existence, argument type correctness, variable type compatibility, fragment cycle detection, and directive placement validity. Unlike REST APIs where invalid requests produce HTTP 400 errors at runtime, GraphQL's validation rules can be checked entirely statically before network transmission — enabling editor integrations (the GraphQL Language Server Protocol provides inline validation in VS Code and IntelliJ) and pre-execution checks in query gateways. Validation errors caught pre-request prevent server-side resolver execution for invalid operations, improving security and performance. Common validation failures include: requesting a field that doesn't exist on the type (FieldsInSetCanMerge), passing an argument of the wrong type (ProvidedRequiredArguments, ValuesOfCorrectType), using a fragment on an incompatible type (FragmentSpreadTypeExistence), and leaving required variable definitions undefined (NoUndefinedVariables). Our validator uses graphql-js validate() against a schema you provide, running all 26 specification validation rules.

How to Use the Tool

  1. Paste your GraphQL schema SDL into the left "Schema" editor.
  2. Paste the GraphQL operation (query, mutation, or subscription) into the right "Operation" editor.
  3. Click "Validate" — graphql-js parses the schema, builds the type system, then validates the operation against it.
  4. All validation errors are listed with the rule name, error message, and the specific location (line/column) in the operation.
  5. Fix errors and re-validate — a green success banner confirms when the operation passes all 26 validation rules.

Key Features & Specifications

  • Validates GraphQL operations using graphql-js validate() against all 26 specification rules
  • Validates both the schema SDL (syntax and type correctness) and the operation document
  • Reports validation errors with rule name, human-readable message, and line/column location
  • Detects unknown fields, wrong argument types, undefined variables, and fragment cycles
  • Side-by-side schema and operation editors for efficient iteration

Frequently Asked Questions (FAQ)

Q:Can I validate a GraphQL query without a schema?
Syntactic validation (is the document grammatically valid?) can be performed without a schema using graphql-js parse(). However, semantic validation — checking that fields exist, types are correct, and variables are compatible — requires a schema. Without a schema, the validator only checks syntax.
Q:What is the difference between a GraphQL parse error and a validation error?
A parse error occurs when the document is not syntactically valid GraphQL — for example, a missing closing brace or an invalid token. A validation error occurs when the syntax is valid but the query doesn't conform to the schema — for example, requesting a field that doesn't exist on the type. Both prevent the server from executing the operation.
Q:How do I get my actual API's schema to paste into the validator?
Most GraphQL APIs expose an introspection endpoint. Run an introspection query using your HTTP client or use the GraphQL CLI: npx graphql-cli schema download --endpoint https://api.example.com/graphql. The downloaded schema can be converted to SDL format and pasted into the schema editor.