Cheatsheet: GraphQL
Last updated 2026-09-23
Schema
Define object types and the root Query type.
Use non-null fields and arguments with !.
Use list types for arrays of values or objects.
Define an input type for structured mutation arguments.
Define enums for a fixed set of allowed values.
Define interfaces for fields shared by multiple object types.
Queries
Execute a simple query with a nested selection set.
Pass arguments to fields.
Use aliases to request the same field with different arguments.
Use variables instead of hard-coding argument values.
Use fragments to reuse field selections.
Use inline fragments for unions or interfaces.
Operations and directives
Execute a mutation and request fields from the payload.
Execute a subscription for real-time updates where supported by the server.
Conditionally include fields with @include.
Conditionally skip fields with @skip.
Use operation names to identify requests in logs and tooling.
Introspection
List available query fields with introspection.
Inspect a type and its fields.
Pagination, defaults, and error shape
Give a variable a default value, used only when the client omits it entirely.
Cursor-based pagination: request the next page after a given cursor.
A response can contain both data and errors -- a failed nullable field becomes null with a matching error entry.
Prefer non-null list and item types for a defensive, easy-to-consume schema.