API reference
GraphQL API reference
GraphQL API design and clients
- Identifiers
- 116
- With full guides
- 51
- Types
- 6
Topics covered
- Schema & types
- Queries & mutations
- Resolvers
- N+1 & DataLoader
- Fragments
- Subscriptions
- Caching
- Federation
Class
| Name | What it does |
|---|---|
GraphQLSchema | GraphQLSchema represents the schema of a GraphQL service: the typed contract describing what data clients can query. Requests are validated and executed against this schema. |
GraphQLObjectType | GraphQLObjectType defines a schema object with named, selectable fields. Each field has an output type and can accept input arguments and resolve its value. |
GraphQLList | GraphQLList represents a GraphQL list type whose items share a declared item type. Lists preserve order and can be combined with non-null wrappers or nested lists. |
GraphQLNonNull | GraphQLNonNull marks a GraphQL type as non-null using !. It guarantees a value for output fields and requires values for inputs, including arguments and input object fields. |
GraphQLEnumType | |
GraphQLInputObjectType | GraphQL Input Object types group related values into a reusable, structured input for field arguments or variables. They use input in SDL and can contain only input-compatible types. |
GraphQLInterfaceType | A GraphQL interface is an abstract type that declares fields shared by concrete object types or other interfaces. It lets a field return different implementing types while clients query their common fields. |
GraphQLUnionType | A GraphQL union is an abstract output type that can resolve to one of several concrete object types. It defines no shared fields, so clients use inline fragments to request member-specific data. |
GraphQLScalarType | |
GraphQLError | GraphQL reports problems in a response-level errors entry. Request errors stop execution and omit data, while field errors can be returned with partial data. |
GraphQLDirective | GraphQL directives use an @-prefixed name to annotate schemas or operations. They can influence validation or execution and may define arguments plus permitted locations. |
Source | |
ApolloServer | ApolloServer is Apollo’s JavaScript GraphQL server. Construct it with schema definitions and resolvers, then run it standalone or connect it to a Node.js HTTP framework. |
ApolloClient | |
InMemoryCache | |
GraphQLArgument | GraphQL arguments are named inputs declared by fields or directives. They can be optional or required, may have defaults, and must use input types. |
GraphQLField | A GraphQL field is a selectable piece of data on an object. Fields can be nested to traverse related objects, accept arguments, and be aliased in the response. |
GraphQLInputField | |
GraphQLEnumValue | |
TypeInfo | |
Lexer | |
Token | |
Kind |
Component
| Name | What it does |
|---|---|
ApolloProvider |
Function
| Name | What it does |
|---|---|
buildSchema | buildSchema builds a GraphQL schema from Schema Definition Language (SDL). The resulting schema describes the types and fields that GraphQL operations can validate and execute against. |
graphql | GraphQL is an API query language and server runtime based on a schema-defined type system. Clients request the fields they need, and the service validates and executes those selections. |
execute | GraphQL execution runs a parsed and validated operation against a schema. It resolves requested fields, completes their values, and returns data shaped like the client’s operation, potentially with errors. |
parse | |
subscribe | GraphQL subscriptions are long-lived operations that deliver selected data when relevant events occur. They use a schema’s Subscription root type and an implementation-selected transport. |
printSchema | printSchema converts a GraphQL schema object into SDL text. The text can be published to a schema registry for governance automation. |
validate | GraphQL validates a parsed operation against the schema before execution. Invalid documents produce request errors and do not begin field execution. |
getNamedType | |
buildClientSchema | |
getIntrospectionQuery | getIntrospectionQuery returns a standard GraphQL query string that asks an endpoint for schema metadata. Clients can send it to discover the API’s types, fields, descriptions, and other introspection information. |
buildASTSchema | |
extendSchema | |
lexicographicSortSchema | |
isObjectType | |
isScalarType | |
coerceInputValue | |
valueFromAST | |
astFromValue | |
visit | |
separateOperations | Separate operations by defining multiple named GraphQL operations in one document, then selecting the desired operation at request time. This supports reusable documents and lets clients choose among queries, mutations, or subscriptions. |
print | |
specifiedRules | |
makeExecutableSchema | makeExecutableSchema combines GraphQL type definitions with resolvers to produce an executable schema. The result can be passed to a graphql-js-based server. |
mergeTypeDefs | |
mergeResolvers | |
createYoga | |
createSchema | |
gql | |
getNullableType | |
isInputType | |
isOutputType | |
isLeafType | |
isCompositeType | |
isAbstractType | |
isWrappingType | |
isNullableType | |
assertValidSchema | |
findBreakingChanges | |
getOperationAST | |
defaultFieldResolver | defaultFieldResolver is the conventional behavior used by many GraphQL libraries when no field resolver is supplied: read the same-named property from the parent object and return it. It suits simple fields whose values are already present on that object. |
stripIgnoredCharacters | |
concatAST | |
formatError | |
introspectionFromSchema | GraphQL introspection lets clients query an API’s schema itself. The __schema field exposes schema-level information, while related introspection fields reveal type details and runtime type names. |
locatedError | |
syntaxError | A GraphQL syntax error is a request error raised when the server cannot parse the document, for example because of a missing bracket or invalid operation keyword. It is reported before execution, so the response has errors but no data. |
makeVar | |
ApolloLink | |
HttpLink | |
onError | |
setContext |
Hook
| Name | What it does |
|---|---|
useQuery | |
useMutation | |
useSubscription | |
useLazyQuery | |
useApolloClient | |
useFragment | |
useReactiveVar | |
useReadQuery | |
useSuspenseQuery | |
useBackgroundQuery |
Const
| Name | What it does |
|---|---|
GraphQLString | |
GraphQLInt | |
GraphQLID | GraphQLID corresponds to GraphQL’s built-in ID scalar. It represents an opaque unique identifier, commonly used to refetch objects or as a cache key, and is serialized like a string. |
GraphQLBoolean | |
GraphQLFloat | GraphQLFloat is GraphQL’s built-in Float scalar for finite signed double-precision IEEE 754 values. It accepts integer or floating-point inputs, while invalid or non-finite values cause errors. |
Query | A GraphQL query is a read operation that starts at the Query root and selects fields through nested objects to scalar or enum leaves. Its selection set lets clients request precisely the data they need, optionally using names, variables, aliases, and fragments. |
Mutation | A GraphQL mutation is an operation for changing server-side data and selecting the resulting data. Mutation fields are exposed on the schema’s Mutation root and execute serially at the top level. |
Subscription | GraphQL subscriptions are long-lived operations for receiving incremental updates when server-side events occur. They use fields on a Subscription root type and are started with the subscription keyword. |
type | GraphQL's ID scalar is used for object identifiers. The global object identification convention makes IDs reusable for caching, refetching, and fetching objects through a standard node field. |
input | GraphQL's ID scalar represents an object identifier and is commonly used in an id field argument. It supports service-defined identifier formats while presenting serialized IDs consistently as strings. |
enum | GraphQL enums are scalar-like leaf types constrained to a finite set of named values. They validate enum arguments and describe the possible values a field can return. |
interface | A GraphQL interface is an abstract type that declares shared fields for object or interface implementations. It lets one field return different concrete types through a common contract. |
union | A GraphQL union is an abstract output type that can resolve to one of several concrete object types. It declares no shared fields, so clients use fragments to request member-specific data. |
scalar | A GraphQL scalar is a leaf type that resolves to one concrete value and cannot have nested selections. GraphQL includes Int, Float, String, Boolean, and ID, and services can define custom scalars. |
schema | A GraphQL schema defines the types and capabilities available from a service. GraphQL validates incoming operations against this contract before executing them, so clients can request supported data predictably. |
fragment | GraphQL fragments are reusable field selections that can be spread into queries. Named fragments support composition, while inline fragments select fields for a concrete type returned through an interface or union. |
directive | A GraphQL directive is an @ annotation that changes how a schema or operation is interpreted. Directives may annotate schema definitions, affect client operations, and are restricted to declared locations. |
resolver | A resolver is the server function behind a GraphQL field. GraphQL invokes it during execution, passes field context and inputs, and uses its result to resolve nested selections or produce a leaf value. |
SDL | SDL, or Schema Definition Language, is GraphQL’s language-agnostic notation for defining the types and fields exposed by a service. Server libraries can use those declarations while resolver functions separately provide field data. |
DataLoader | DataLoader batches keyed data fetches and memoizes repeated keys, helping GraphQL resolvers avoid duplicate backend requests. Create it with a function that maps a list of keys to the corresponding objects. |
N+1 problem | The N+1 problem occurs when resolving one list triggers an additional backend request for each item, producing one initial request plus N follow-up requests. GraphQL performance guidance recommends batching and caching related loads, or translating selection sets into optimized data-source queries. |
field resolver | A field resolver is the server function that supplies a value for a GraphQL field. GraphQL calls resolvers from the root operation fields through nested selections until the requested leaf values are produced. |
root value | A GraphQL operation starts at a root operation type. For queries, that root is the Query object, which provides the first fields the client can select. |
context | GraphQL is commonly served through one HTTP endpoint, typically /graphql. Clients send JSON requests, usually with POST, and receive results under data plus any validation or execution errors under errors. |
schema stitching | |
federation | GraphQL federation combines independently managed subgraphs into one schema exposed through a gateway. Clients query the unified schema while the gateway routes work to the responsible services. |
persisted queries | Persisted queries let clients send a query hash instead of the full GraphQL document. The server retrieves the stored document before validating and executing it, reducing request size. |
Directive
| Name | What it does |
|---|---|
@deprecated | @deprecated marks a GraphQL field or enum value as obsolete while keeping it available to clients. Its optional reason tells users what to use instead. |
@skip | @skip conditionally omits a field or fragment when its Boolean if argument is true. It lets one query make optional selections controlled by a literal or runtime variable. |
@include | @include conditionally includes a field or fragment when its required if argument evaluates to true. Use it to let runtime variables control whether optional selections are requested. |
@specifiedBy | @specifiedBy documents a custom scalar by attaching a URL for its specification. The URL should explain the scalar’s format, serialization, and coercion rules. |
Search across every package and filter by type in your dashboard.
Start learning