Skip to content
uencoder

GraphQL Schema Definition Reference

Reference for GraphQL schema language: types, interfaces, unions, enums, and directives.

Type System

GraphQL schemas define object types with fields, each having a type and optional arguments. Scalar types (Int, Float, String, Boolean, ID) are built-in; custom scalars can be declared. Interfaces define contracts that object types implement. Unions allow fields to return one of several types. Enums restrict fields to a set of named values. Input types structure mutation arguments.

object type
Fields with types
type User { id: ID! }
interface
Contract for objects
implements Node
union
One of several types
union Result = User | Error

Schema Elements

The Query, Mutation, and Subscription root types define entry points. Field arguments can have default values and be required (suffix !). List types use [Type] syntax. Directives (prefixed @) annotate fields for validation, caching, or deprecation. Schema directives can be custom-defined. The introspection system allows querying the schema itself. SDL (Schema Definition Language) is the human-readable format.

root types
Query, Mutation, Subscription
entry points
!
Non-null marker
required field/arg
directives
@-prefixed annotations
@deprecated, @cache

Related tools

References