Last updated
Validation Checklist
- Syntax valid — no missing braces, colons, or invalid tokens
- All fields exist on their parent types in the schema
- All required arguments are provided
- Variable types match argument types
- No deprecated fields used (or deprecation acknowledged)
- Query complexity within acceptable limits
- No N+1 patterns in list queries
- All fragments are used and valid
- Live endpoint returns expected data structure
- Error cases return appropriate error responses
Examples
Example 1: Syntax Validation
The tester catches syntax errors before execution:
# Invalid — missing closing brace
query GetUser($id: ID!) {
user(id: $id) {
id
name
email
# ← missing closing brace
Error:
Line 7, Column 1: Expected "}", found EOF
Suggestion: Add closing "}" to complete the selection set
# Invalid — incorrect argument syntax
query {
user(id "123") { # ← missing colon
name
}
}
Error:
Line 2, Column 12: Expected ":", found String "123"
Suggestion: Use "id: \"123\"" for argument syntax
Example 2: Schema Validation
Validate a query against a schema to catch type errors:
# Schema:
type Query {
user(id: ID!): User
}
type User {
id: ID!
name: String!
email: String!
}
# Query with invalid field:
query {
user(id: "123") {
id
name
phoneNumber # ← field doesn't exist
}
}
Validation Error:
Field "phoneNumber" does not exist on type "User"
Available fields: id, name, email
Example 3: Variable Type Validation
# Query:
query GetUser($id: ID!) {
user(id: $id) {
name
}
}
# Variables — wrong type:
{
"id": 123 # ← number, but ID! expects a string
}
Validation Error:
Variable "$id" of type "ID!" was provided invalid value.
Expected: String or Int coercible to ID
Received: 123 (Int)
Fix: Use "id": "123" (string)