graphql/type/definitions
Classes
GraphQLList
List Type Wrapper
A list is a wrapping type which points to another type. Lists are often created within the context of defining the fields of an object type.
Example:
const PersonType = new GraphQLObjectType({
name: 'Person',
fields: () => ({
parents: { type: new GraphQLList(PersonType) },
children: { type: new GraphQLList(PersonType) },
})
})Type Parameters
| Name | Constraint | Default | Description |
|---|---|---|---|
| T | GraphQLType | The GraphQL type wrapped by this list type. |
Constructor
Creates a GraphQLList instance.
Signature:
new GraphQLList(ofType: T)
Arguments
| Name | Type | Description |
|---|---|---|
| ofType | T | The type to wrap. |
Returns
| Type | Description |
|---|---|
GraphQLList<T> |
Members
| Name | Type | Description |
|---|---|---|
| ofType | T | The type wrapped by this list or non-null type. |
toString()
Returns this wrapping type as a GraphQL type-reference string.
Signature:
toString(): string
Returns
| Type | Description |
|---|---|
string | The GraphQL type-reference string. |
Example
const source = listType.toString();
// source: GraphQL type-reference syntax, for example '[String]'toJSON()
Returns the JSON representation used when this object is serialized.
Signature:
toJSON(): string
Returns
| Type | Description |
|---|---|
string | The JSON-serializable representation. |
Example
const json = listType.toJSON();
// json: the JSON representationGraphQLNonNull
Non-Null Type Wrapper
A non-null is a wrapping type which points to another type. Non-null types enforce that their values are never null and can ensure an error is raised if this ever occurs during a request. It is useful for fields which you can make a strong guarantee on non-nullability, for example usually the id field of a database row will never be null.
Example:
const RowType = new GraphQLObjectType({
name: 'Row',
fields: () => ({
id: { type: new GraphQLNonNull(GraphQLString) },
})
})Note: the enforcement of non-nullability occurs within the executor.
Type Parameters
| Name | Constraint | Default | Description |
|---|---|---|---|
| T | GraphQLNullableType | The nullable GraphQL type wrapped by this non-null type. |
Constructor
Creates a GraphQLNonNull instance.
Signature:
new GraphQLNonNull(ofType: T)
Arguments
| Name | Type | Description |
|---|---|---|
| ofType | T | The type to wrap. |
Returns
| Type | Description |
|---|---|
GraphQLNonNull<T> |
Members
| Name | Type | Description |
|---|---|---|
| ofType | T | The type wrapped by this list or non-null type. |
toString()
Returns this wrapping type as a GraphQL type-reference string.
Signature:
toString(): string
Returns
| Type | Description |
|---|---|
string | The GraphQL type-reference string. |
Example
const source = nonNullType.toString();
// source: GraphQL type-reference syntax, for example 'String!'toJSON()
Returns the JSON representation used when this object is serialized.
Signature:
toJSON(): string
Returns
| Type | Description |
|---|---|
string | The JSON-serializable representation. |
Example
const json = nonNullType.toJSON();
// json: the JSON representationGraphQLScalarType
Scalar Type Definition
The leaf values of any request and input values to arguments are Scalars (or Enums) and are defined with a name and a series of functions used to parse input from ast or variables and to ensure validity.
If a type’s serialize function returns null or does not return a value
(i.e. it returns undefined) then an error will be raised and a null
value will be returned in the response. It is always better to validate
Example:
const OddType = new GraphQLScalarType({
name: 'Odd',
serialize(value) {
if (!Number.isFinite(value)) {
throw new Error(
`Scalar "Odd" cannot represent "${value}" since it is not a finite number.`,
);
}
if (value % 2 === 0) {
throw new Error(`Scalar "Odd" cannot represent "${value}" since it is even.`);
}
return value;
}
});Type Parameters
| Name | Constraint | Default | Description |
|---|---|---|---|
| TInternal | unknown | The internal runtime representation accepted by this scalar. | |
| TExternal | TInternal | The serialized representation exposed in GraphQL results. |
Constructor
Creates a GraphQLScalarType instance.
Signature:
new GraphQLScalarType(config: Readonly<GraphQLScalarTypeConfig<TInternal, TExternal>>)
Arguments
| Name | Type | Description |
|---|---|---|
| config | Readonly<GraphQLScalarTypeConfig<TInternal, TExternal>> | Configuration describing this object. |
Returns
| Type | Description |
|---|---|
GraphQLScalarType<TInternal, TExternal> |
Members
| Name | Type | Description |
|---|---|---|
| name | string | The GraphQL name for this schema element. |
| description | null | undefined | string | Human-readable description for this schema element, if provided. |
| specifiedByURL | null | undefined | string | URL identifying the behavior specified for this custom scalar. |
| serialize | GraphQLScalarSerializer<TExternal> | Function that converts internal values to externally visible scalar values. |
| parseValue | GraphQLScalarValueParser<TInternal> | Function that converts variable input into this scalar’s internal value. |
| parseLiteral | GraphQLScalarLiteralParser<TInternal> | Function that converts AST input literals into this scalar’s internal value. |
| extensions | Readonly<GraphQLScalarTypeExtensions> | Extension fields to include in the formatted result. |
| astNode | null | undefined | ScalarTypeDefinitionNode | AST node from which this schema element was built, if available. |
| extensionASTNodes | readonly ScalarTypeExtensionNode[] | AST extension nodes applied to this schema element. |
toConfig()
Returns a normalized configuration object for this object.
Signature:
toConfig(): { serialize: GraphQLScalarSerializer<TExternal>; parseValue: GraphQLScalarValueParser<TInternal>; parseLiteral: GraphQLScalarLiteralParser<TInternal>; extensions: Readonly<GraphQLScalarTypeExtensions>; extensionASTNodes: ReadonlyArray<ScalarTypeExtensionNode> }
Returns
| Type | Description |
|---|---|
{ serialize: GraphQLScalarSerializer<TExternal>; parseValue: GraphQLScalarValueParser<TInternal>; parseLiteral: GraphQLScalarLiteralParser<TInternal>; extensions: Readonly<GraphQLScalarTypeExtensions>; extensionASTNodes: ReadonlyArray<ScalarTypeExtensionNode> } | A configuration object that can be used to recreate this object. |
Example
// Given a GraphQLScalarType instance named scalarType:
const result = scalarType.toConfig();
// result contains the toConfig return valuetoString()
Returns the schema coordinate identifying this scalar type.
Signature:
toString(): string
Returns
| Type | Description |
|---|---|
string | The schema coordinate for this scalar type. |
Example
const coordinate = scalarType.toString();
// coordinate: the type schema coordinate, for example 'DateTime'toJSON()
Returns the JSON representation used when this object is serialized.
Signature:
toJSON(): string
Returns
| Type | Description |
|---|---|
string | The JSON-serializable representation. |
Example
const json = scalarType.toJSON();
// json: the JSON representationGraphQLObjectType
Object Type Definition
Almost all of the GraphQL types you define will be object types. Object types have a name, but most importantly describe their fields.
Example:
const AddressType = new GraphQLObjectType({
name: 'Address',
fields: {
street: { type: GraphQLString },
number: { type: GraphQLInt },
formatted: {
type: GraphQLString,
resolve(obj) {
return obj.number + ' ' + obj.street
}
}
}
});When two types need to refer to each other, or a type needs to refer to itself in a field, you can use a function expression (aka a closure or a thunk) to supply the fields lazily.
Example:
const PersonType = new GraphQLObjectType({
name: 'Person',
fields: () => ({
name: { type: GraphQLString },
bestFriend: { type: PersonType },
})
});Type Parameters
| Name | Constraint | Default | Description |
|---|---|---|---|
| TSource | any | The JavaScript source value type resolved as this object type. | |
| TContext | any | The application context type passed to this object type’s resolvers. |
Constructor
Creates a GraphQLObjectType instance.
Signature:
new GraphQLObjectType(config: Readonly<GraphQLObjectTypeConfig<TSource, TContext>>)
Arguments
| Name | Type | Description |
|---|---|---|
| config | Readonly<GraphQLObjectTypeConfig<TSource, TContext>> | Configuration describing this object. |
Returns
| Type | Description |
|---|---|
GraphQLObjectType<TSource, TContext> |
Members
| Name | Type | Description |
|---|---|---|
| name | string | The GraphQL name for this schema element. |
| description | null | undefined | string | Human-readable description for this schema element, if provided. |
| isTypeOf | null | undefined | GraphQLIsTypeOfFn<TSource, TContext> | Predicate used to determine whether a runtime value belongs to this object type. |
| extensions | Readonly<GraphQLObjectTypeExtensions<TSource, TContext>> | Extension fields to include in the formatted result. |
| astNode | null | undefined | ObjectTypeDefinitionNode | AST node from which this schema element was built, if available. |
| extensionASTNodes | readonly ObjectTypeExtensionNode[] | AST extension nodes applied to this schema element. |
getFields()
Returns the fields defined by this type.
Signature:
getFields(): GraphQLFieldMap<TSource, TContext>
Returns
| Type | Description |
|---|---|
GraphQLFieldMap<TSource, TContext> | The fields keyed by field name. |
Example
// Given a GraphQLObjectType instance named objectType:
const result = objectType.getFields();
// result contains the getFields return valuegetInterfaces()
Returns the interfaces implemented by this type.
Signature:
getInterfaces(): readonly GraphQLInterfaceType[]
Returns
| Type | Description |
|---|---|
readonly GraphQLInterfaceType[] | The implemented interfaces. |
Example
// Given a GraphQLObjectType instance named objectType:
const result = objectType.getInterfaces();
// result contains the getInterfaces return valuetoConfig()
Returns a normalized configuration object for this object.
Signature:
toConfig(): { interfaces: ReadonlyArray<GraphQLInterfaceType>; fields: GraphQLFieldConfigMap<any, any>; extensions: Readonly<GraphQLObjectTypeExtensions<TSource, TContext>>; extensionASTNodes: ReadonlyArray<ObjectTypeExtensionNode> }
Returns
| Type | Description |
|---|---|
{ interfaces: ReadonlyArray<GraphQLInterfaceType>; fields: GraphQLFieldConfigMap<any, any>; extensions: Readonly<GraphQLObjectTypeExtensions<TSource, TContext>>; extensionASTNodes: ReadonlyArray<ObjectTypeExtensionNode> } | A configuration object that can be used to recreate this object. |
Example
// Given a GraphQLObjectType instance named objectType:
const result = objectType.toConfig();
// result contains the toConfig return valuetoString()
Returns the schema coordinate identifying this object type.
Signature:
toString(): string
Returns
| Type | Description |
|---|---|
string | The schema coordinate for this object type. |
Example
const coordinate = objectType.toString();
// coordinate: the type schema coordinate, for example 'User'toJSON()
Returns the JSON representation used when this object is serialized.
Signature:
toJSON(): string
Returns
| Type | Description |
|---|---|
string | The JSON-serializable representation. |
Example
const json = objectType.toJSON();
// json: the JSON representationGraphQLInterfaceType
Interface Type Definition
When a field can return one of a heterogeneous set of types, a Interface type is used to describe what types are possible, what fields are in common across all types, as well as a function to determine which type is actually used when the field is resolved.
Example:
const EntityType = new GraphQLInterfaceType({
name: 'Entity',
fields: {
name: { type: GraphQLString }
}
});Constructor
Creates a GraphQLInterfaceType instance.
Signature:
new GraphQLInterfaceType(config: Readonly<GraphQLInterfaceTypeConfig<any, any>>)
Arguments
| Name | Type | Description |
|---|---|---|
| config | Readonly<GraphQLInterfaceTypeConfig<any, any>> | Configuration describing this object. |
Returns
| Type | Description |
|---|---|
GraphQLInterfaceType |
Members
| Name | Type | Description |
|---|---|---|
| name | string | The GraphQL name for this schema element. |
| description | null | undefined | string | Human-readable description for this schema element, if provided. |
| resolveType | null | undefined | GraphQLTypeResolver<any, any> | Function that resolves the concrete object type for this abstract type. |
| extensions | Readonly<GraphQLInterfaceTypeExtensions> | Extension fields to include in the formatted result. |
| astNode | null | undefined | InterfaceTypeDefinitionNode | AST node from which this schema element was built, if available. |
| extensionASTNodes | readonly InterfaceTypeExtensionNode[] | AST extension nodes applied to this schema element. |
getFields()
Returns the fields defined by this type.
Signature:
getFields(): GraphQLFieldMap<any, any>
Returns
| Type | Description |
|---|---|
GraphQLFieldMap<any, any> | The fields keyed by field name. |
Example
// Given a GraphQLInterfaceType instance named interfaceType:
const result = interfaceType.getFields();
// result contains the getFields return valuegetInterfaces()
Returns the interfaces implemented by this type.
Signature:
getInterfaces(): readonly GraphQLInterfaceType[]
Returns
| Type | Description |
|---|---|
readonly GraphQLInterfaceType[] | The implemented interfaces. |
Example
// Given a GraphQLInterfaceType instance named interfaceType:
const result = interfaceType.getInterfaces();
// result contains the getInterfaces return valuetoConfig()
Returns a normalized configuration object for this object.
Signature:
toConfig(): { interfaces: ReadonlyArray<GraphQLInterfaceType>; fields: GraphQLFieldConfigMap<any, any>; extensions: Readonly<GraphQLInterfaceTypeExtensions>; extensionASTNodes: ReadonlyArray<InterfaceTypeExtensionNode> }
Returns
| Type | Description |
|---|---|
{ interfaces: ReadonlyArray<GraphQLInterfaceType>; fields: GraphQLFieldConfigMap<any, any>; extensions: Readonly<GraphQLInterfaceTypeExtensions>; extensionASTNodes: ReadonlyArray<InterfaceTypeExtensionNode> } | A configuration object that can be used to recreate this object. |
Example
// Given a GraphQLInterfaceType instance named interfaceType:
const result = interfaceType.toConfig();
// result contains the toConfig return valuetoString()
Returns the schema coordinate identifying this interface type.
Signature:
toString(): string
Returns
| Type | Description |
|---|---|
string | The schema coordinate for this interface type. |
Example
const coordinate = interfaceType.toString();
// coordinate: the type schema coordinate, for example 'Node'toJSON()
Returns the JSON representation used when this object is serialized.
Signature:
toJSON(): string
Returns
| Type | Description |
|---|---|
string | The JSON-serializable representation. |
Example
const json = interfaceType.toJSON();
// json: the JSON representationGraphQLUnionType
Union Type Definition
When a field can return one of a heterogeneous set of types, a Union type is used to describe what types are possible as well as providing a function to determine which type is actually used when the field is resolved.
Example:
const PetType = new GraphQLUnionType({
name: 'Pet',
types: [ DogType, CatType ],
resolveType(value) {
if (value instanceof Dog) {
return DogType;
}
if (value instanceof Cat) {
return CatType;
}
}
});Constructor
Creates a GraphQLUnionType instance.
Signature:
new GraphQLUnionType(config: Readonly<GraphQLUnionTypeConfig<any, any>>)
Arguments
| Name | Type | Description |
|---|---|---|
| config | Readonly<GraphQLUnionTypeConfig<any, any>> | Configuration describing this object. |
Returns
| Type | Description |
|---|---|
GraphQLUnionType |
Members
| Name | Type | Description |
|---|---|---|
| name | string | The GraphQL name for this schema element. |
| description | null | undefined | string | Human-readable description for this schema element, if provided. |
| resolveType | null | undefined | GraphQLTypeResolver<any, any> | Function that resolves the concrete object type for this abstract type. |
| extensions | Readonly<GraphQLUnionTypeExtensions> | Extension fields to include in the formatted result. |
| astNode | null | undefined | UnionTypeDefinitionNode | AST node from which this schema element was built, if available. |
| extensionASTNodes | readonly UnionTypeExtensionNode[] | AST extension nodes applied to this schema element. |
getTypes()
Returns the object types included in this union.
Signature:
getTypes(): readonly GraphQLObjectType[]
Returns
| Type | Description |
|---|---|
readonly GraphQLObjectType[] | The union member object types. |
Example
// Given a GraphQLUnionType instance named unionType:
const result = unionType.getTypes();
// result contains the getTypes return valuetoConfig()
Returns a normalized configuration object for this object.
Signature:
toConfig(): { types: ReadonlyArray<GraphQLObjectType>; extensions: Readonly<GraphQLUnionTypeExtensions>; extensionASTNodes: ReadonlyArray<UnionTypeExtensionNode> }
Returns
| Type | Description |
|---|---|
{ types: ReadonlyArray<GraphQLObjectType>; extensions: Readonly<GraphQLUnionTypeExtensions>; extensionASTNodes: ReadonlyArray<UnionTypeExtensionNode> } | A configuration object that can be used to recreate this object. |
Example
// Given a GraphQLUnionType instance named unionType:
const result = unionType.toConfig();
// result contains the toConfig return valuetoString()
Returns the schema coordinate identifying this union type.
Signature:
toString(): string
Returns
| Type | Description |
|---|---|
string | The schema coordinate for this union type. |
Example
const coordinate = unionType.toString();
// coordinate: the type schema coordinate, for example 'SearchResult'toJSON()
Returns the JSON representation used when this object is serialized.
Signature:
toJSON(): string
Returns
| Type | Description |
|---|---|
string | The JSON-serializable representation. |
Example
const json = unionType.toJSON();
// json: the JSON representationGraphQLEnumType
Enum Type Definition
Some leaf values of requests and input values are Enums. GraphQL serializes Enum values as strings, however internally Enums can be represented by any kind of type, often integers.
Example:
const RGBType = new GraphQLEnumType({
name: 'RGB',
values: {
RED: { value: 0 },
GREEN: { value: 1 },
BLUE: { value: 2 }
}
});Note: If a value is not provided in a definition, the name of the enum value will be used as its internal value.
Constructor
Creates a GraphQLEnumType instance.
Signature:
new GraphQLEnumType(config: Readonly<GraphQLEnumTypeConfig>)
Arguments
| Name | Type | Description |
|---|---|---|
| config | Readonly<GraphQLEnumTypeConfig> | Configuration describing this object. |
Returns
| Type | Description |
|---|---|
GraphQLEnumType |
Members
| Name | Type | Description |
|---|---|---|
| name | string | The GraphQL name for this schema element. |
| description | null | undefined | string | Human-readable description for this schema element, if provided. |
| extensions | Readonly<GraphQLEnumTypeExtensions> | Extension fields to include in the formatted result. |
| astNode | null | undefined | EnumTypeDefinitionNode | AST node from which this schema element was built, if available. |
| extensionASTNodes | readonly EnumTypeExtensionNode[] | AST extension nodes applied to this schema element. |
getValues()
Returns the values defined by this enum type.
Signature:
getValues(): readonly GraphQLEnumValue[]
Returns
| Type | Description |
|---|---|
readonly GraphQLEnumValue[] | The enum values. |
Example
// Given a GraphQLEnumType instance named enumType:
const result = enumType.getValues();
// result contains the getValues return valuegetValue()
Returns the enum value definition for a value name.
Signature:
getValue(name: string): null | undefined | GraphQLEnumValue
Arguments
| Name | Type | Description |
|---|---|---|
| name | string | The GraphQL name to look up. |
Returns
| Type | Description |
|---|---|
null | undefined | GraphQLEnumValue | The matching enum value definition, if it exists. |
Example
// Given a GraphQLEnumType instance named enumType:
const result = enumType.getValue(name);
// result contains the getValue return valueserialize()
Serializes a runtime enum value as a GraphQL enum name.
Signature:
serialize(outputValue: unknown): null | undefined | string
Arguments
| Name | Type | Description |
|---|---|---|
| outputValue | unknown | Runtime enum value to serialize. |
Returns
| Type | Description |
|---|---|
null | undefined | string | The GraphQL enum name for the runtime value. |
Example
// Given a GraphQLEnumType instance named enumType:
const result = enumType.serialize(outputValue);
// result contains the serialize return valueparseValue()
Parses a GraphQL enum name from variable input.
Signature:
parseValue(inputValue: unknown): any
Arguments
| Name | Type | Description |
|---|---|---|
| inputValue | unknown | Runtime input value to parse. |
Returns
| Type | Description |
|---|---|
any | The internal enum value represented by the input name. |
Example
// Given a GraphQLEnumType instance named enumType:
const result = enumType.parseValue(inputValue);
// result contains the parseValue return valueparseLiteral()
Parses a GraphQL enum name from an AST value literal.
Signature:
parseLiteral(valueNode: ValueNode, _variables: null | undefined | object): any
Arguments
| Name | Type | Description |
|---|---|---|
| valueNode | ValueNode | AST value literal to parse. |
| _variables | null | undefined | object | Runtime variable values; ignored because enum literals cannot contain variables. |
Returns
| Type | Description |
|---|---|
any | The internal enum value represented by the literal. |
Example
// Given a GraphQLEnumType instance named enumType:
const result = enumType.parseLiteral(valueNode, _variables);
// result contains the parseLiteral return valuetoConfig()
Returns a normalized configuration object for this object.
Signature:
toConfig(): { values: object; extensions: Readonly<GraphQLEnumTypeExtensions>; extensionASTNodes: ReadonlyArray<EnumTypeExtensionNode> }
Returns
| Type | Description |
|---|---|
{ values: object; extensions: Readonly<GraphQLEnumTypeExtensions>; extensionASTNodes: ReadonlyArray<EnumTypeExtensionNode> } | A configuration object that can be used to recreate this object. |
Example
// Given a GraphQLEnumType instance named enumType:
const result = enumType.toConfig();
// result contains the toConfig return valuetoString()
Returns the schema coordinate identifying this enum type.
Signature:
toString(): string
Returns
| Type | Description |
|---|---|
string | The schema coordinate for this enum type. |
Example
const coordinate = enumType.toString();
// coordinate: the type schema coordinate, for example 'Episode'toJSON()
Returns the JSON representation used when this object is serialized.
Signature:
toJSON(): string
Returns
| Type | Description |
|---|---|
string | The JSON-serializable representation. |
Example
const json = enumType.toJSON();
// json: the JSON representationGraphQLInputObjectType
Input Object Type Definition
An input object defines a structured collection of fields which may be supplied to a field argument.
Using NonNull will ensure that a value must be provided by the query
Example:
const GeoPoint = new GraphQLInputObjectType({
name: 'GeoPoint',
fields: {
lat: { type: new GraphQLNonNull(GraphQLFloat) },
lon: { type: new GraphQLNonNull(GraphQLFloat) },
alt: { type: GraphQLFloat, defaultValue: 0 },
}
});Constructor
Creates a GraphQLInputObjectType instance.
Signature:
new GraphQLInputObjectType(config: Readonly<GraphQLInputObjectTypeConfig>)
Arguments
| Name | Type | Description |
|---|---|---|
| config | Readonly<GraphQLInputObjectTypeConfig> | Configuration describing this object. |
Returns
| Type | Description |
|---|---|
GraphQLInputObjectType |
Members
| Name | Type | Description |
|---|---|---|
| name | string | The GraphQL name for this schema element. |
| description | null | undefined | string | Human-readable description for this schema element, if provided. |
| extensions | Readonly<GraphQLInputObjectTypeExtensions> | Extension fields to include in the formatted result. |
| astNode | null | undefined | InputObjectTypeDefinitionNode | AST node from which this schema element was built, if available. |
| extensionASTNodes | readonly InputObjectTypeExtensionNode[] | AST extension nodes applied to this schema element. |
| isOneOf | boolean | Whether this input object uses the experimental OneOf input object semantics. |
getFields()
Returns the fields defined by this type.
Signature:
getFields(): GraphQLInputFieldMap
Returns
| Type | Description |
|---|---|
GraphQLInputFieldMap | The fields keyed by field name. |
Example
// Given a GraphQLInputObjectType instance named inputObjectType:
const result = inputObjectType.getFields();
// result contains the getFields return valuetoConfig()
Returns a normalized configuration object for this object.
Signature:
toConfig(): { fields: GraphQLInputFieldConfigMap; extensions: Readonly<GraphQLInputObjectTypeExtensions>; extensionASTNodes: ReadonlyArray<InputObjectTypeExtensionNode> }
Returns
| Type | Description |
|---|---|
{ fields: GraphQLInputFieldConfigMap; extensions: Readonly<GraphQLInputObjectTypeExtensions>; extensionASTNodes: ReadonlyArray<InputObjectTypeExtensionNode> } | A configuration object that can be used to recreate this object. |
Example
// Given a GraphQLInputObjectType instance named inputObjectType:
const result = inputObjectType.toConfig();
// result contains the toConfig return valuetoString()
Returns the schema coordinate identifying this input object type.
Signature:
toString(): string
Returns
| Type | Description |
|---|---|
string | The schema coordinate for this input object type. |
Example
const coordinate = inputObjectType.toString();
// coordinate: the type schema coordinate, for example 'ReviewInput'toJSON()
Returns the JSON representation used when this object is serialized.
Signature:
toJSON(): string
Returns
| Type | Description |
|---|---|
string | The JSON-serializable representation. |
Example
const json = inputObjectType.toJSON();
// json: the JSON representationFunctions
isType()
Returns true when the value is any GraphQL type.
Signature:
isType(type: unknown): type is GraphQLType
Arguments
| Name | Type | Description |
|---|---|---|
| type | unknown | The GraphQL type to inspect. |
Returns
| Type | Description |
|---|---|
type is GraphQLType | True when the value matches this type. |
Example
import { isType, GraphQLString } from 'graphql/type';
const result = isType(GraphQLString);
// result: true for matching GraphQL typesassertType()
Returns the value as a GraphQL type, or throws if it is not one.
Signature:
assertType(type: unknown): GraphQLType
Arguments
| Name | Type | Description |
|---|---|---|
| type | unknown | The GraphQL type to inspect. |
Returns
| Type | Description |
|---|---|
GraphQLType | The value typed as a GraphQL type. |
Example
import { assertType, GraphQLString } from 'graphql/type';
const type = assertType(GraphQLString);
// type: GraphQLStringisScalarType()
There are predicates for each kind of GraphQL type.
Signature:
isScalarType(type: unknown): type is GraphQLScalarType<unknown, unknown>
Arguments
| Name | Type | Description |
|---|---|---|
| type | unknown | The GraphQL type to inspect. |
Returns
| Type | Description |
|---|---|
type is GraphQLScalarType<unknown, unknown> | True when the value matches this type. |
Example
import { isScalarType, GraphQLString } from 'graphql/type';
const result = isScalarType(GraphQLString);
// result: true for matching GraphQL typesassertScalarType()
Returns the value as a GraphQLScalarType, or throws if it is not one.
Signature:
assertScalarType(type: unknown): GraphQLScalarType
Arguments
| Name | Type | Description |
|---|---|---|
| type | unknown | The GraphQL type to inspect. |
Returns
| Type | Description |
|---|---|
GraphQLScalarType | The value typed as a GraphQLScalarType. |
Example
import { assertScalarType, GraphQLString } from 'graphql/type';
const type = assertScalarType(GraphQLString);
// type: GraphQLStringisObjectType()
Returns true when the value is a GraphQLObjectType.
Signature:
isObjectType(type: unknown): type is GraphQLObjectType
Arguments
| Name | Type | Description |
|---|---|---|
| type | unknown | The GraphQL type to inspect. |
Returns
| Type | Description |
|---|---|
type is GraphQLObjectType | True when the value matches this type. |
Example
import { isObjectType, GraphQLString } from 'graphql/type';
const result = isObjectType(GraphQLString);
// result: true for matching GraphQL typesassertObjectType()
Returns the value as a GraphQLObjectType, or throws if it is not one.
Signature:
assertObjectType(type: unknown): GraphQLObjectType
Arguments
| Name | Type | Description |
|---|---|---|
| type | unknown | The GraphQL type to inspect. |
Returns
| Type | Description |
|---|---|
GraphQLObjectType | The value typed as a GraphQLObjectType. |
Example
import { assertObjectType, GraphQLString } from 'graphql/type';
const type = assertObjectType(GraphQLString);
// type: GraphQLStringisInterfaceType()
Returns true when the value is a GraphQLInterfaceType.
Signature:
isInterfaceType(type: unknown): type is GraphQLInterfaceType
Arguments
| Name | Type | Description |
|---|---|---|
| type | unknown | The GraphQL type to inspect. |
Returns
| Type | Description |
|---|---|
type is GraphQLInterfaceType | True when the value matches this type. |
Example
import { isInterfaceType, GraphQLString } from 'graphql/type';
const result = isInterfaceType(GraphQLString);
// result: true for matching GraphQL typesassertInterfaceType()
Returns the value as a GraphQLInterfaceType, or throws if it is not one.
Signature:
assertInterfaceType(type: unknown): GraphQLInterfaceType
Arguments
| Name | Type | Description |
|---|---|---|
| type | unknown | The GraphQL type to inspect. |
Returns
| Type | Description |
|---|---|
GraphQLInterfaceType | The value typed as a GraphQLInterfaceType. |
Example
import { assertInterfaceType, GraphQLString } from 'graphql/type';
const type = assertInterfaceType(GraphQLString);
// type: GraphQLStringisUnionType()
Returns true when the value is a GraphQLUnionType.
Signature:
isUnionType(type: unknown): type is GraphQLUnionType
Arguments
| Name | Type | Description |
|---|---|---|
| type | unknown | The GraphQL type to inspect. |
Returns
| Type | Description |
|---|---|
type is GraphQLUnionType | True when the value matches this type. |
Example
import { isUnionType, GraphQLString } from 'graphql/type';
const result = isUnionType(GraphQLString);
// result: true for matching GraphQL typesassertUnionType()
Returns the value as a GraphQLUnionType, or throws if it is not one.
Signature:
assertUnionType(type: unknown): GraphQLUnionType
Arguments
| Name | Type | Description |
|---|---|---|
| type | unknown | The GraphQL type to inspect. |
Returns
| Type | Description |
|---|---|
GraphQLUnionType | The value typed as a GraphQLUnionType. |
Example
import { assertUnionType, GraphQLString } from 'graphql/type';
const type = assertUnionType(GraphQLString);
// type: GraphQLStringisEnumType()
Returns true when the value is a GraphQLEnumType.
Signature:
isEnumType(type: unknown): type is GraphQLEnumType
Arguments
| Name | Type | Description |
|---|---|---|
| type | unknown | The GraphQL type to inspect. |
Returns
| Type | Description |
|---|---|
type is GraphQLEnumType | True when the value matches this type. |
Example
import { isEnumType, GraphQLString } from 'graphql/type';
const result = isEnumType(GraphQLString);
// result: true for matching GraphQL typesassertEnumType()
Returns the value as a GraphQLEnumType, or throws if it is not one.
Signature:
assertEnumType(type: unknown): GraphQLEnumType
Arguments
| Name | Type | Description |
|---|---|---|
| type | unknown | The GraphQL type to inspect. |
Returns
| Type | Description |
|---|---|
GraphQLEnumType | The value typed as a GraphQLEnumType. |
Example
import { assertEnumType, GraphQLString } from 'graphql/type';
const type = assertEnumType(GraphQLString);
// type: GraphQLStringisInputObjectType()
Returns true when the value is a GraphQLInputObjectType.
Signature:
isInputObjectType(type: unknown): type is GraphQLInputObjectType
Arguments
| Name | Type | Description |
|---|---|---|
| type | unknown | The GraphQL type to inspect. |
Returns
| Type | Description |
|---|---|
type is GraphQLInputObjectType | True when the value matches this type. |
Example
import { isInputObjectType, GraphQLString } from 'graphql/type';
const result = isInputObjectType(GraphQLString);
// result: true for matching GraphQL typesassertInputObjectType()
Returns the value as a GraphQLInputObjectType, or throws if it is not one.
Signature:
assertInputObjectType(type: unknown): GraphQLInputObjectType
Arguments
| Name | Type | Description |
|---|---|---|
| type | unknown | The GraphQL type to inspect. |
Returns
| Type | Description |
|---|---|
GraphQLInputObjectType | The value typed as a GraphQLInputObjectType. |
Example
import { assertInputObjectType, GraphQLString } from 'graphql/type';
const type = assertInputObjectType(GraphQLString);
// type: GraphQLStringisListType()
Overload 1
Returns true when the value is a GraphQLList.
Signature:
isListType(type: GraphQLInputType): type is GraphQLList<GraphQLInputType>
Arguments
| Name | Type | Description |
|---|---|---|
| type | GraphQLInputType | The GraphQL type to inspect. |
Returns
| Type | Description |
|---|---|
type is GraphQLList<GraphQLInputType> | True when the value matches this type. |
Example
import { GraphQLList, GraphQLString, isListType } from 'graphql/type';
isListType(new GraphQLList(GraphQLString));
// trueOverload 2
Returns true when the output type is a GraphQLList.
Signature:
isListType(type: GraphQLOutputType): type is GraphQLList<GraphQLOutputType>
Arguments
| Name | Type | Description |
|---|---|---|
| type | GraphQLOutputType | The GraphQL output type to inspect. |
Returns
| Type | Description |
|---|---|
type is GraphQLList<GraphQLOutputType> | True when the output type is a list type. |
Overload 3
Returns true when the value is a GraphQLList.
Signature:
isListType(type: unknown): type is GraphQLList<GraphQLType>
Arguments
| Name | Type | Description |
|---|---|---|
| type | unknown | The value to inspect. |
Returns
| Type | Description |
|---|---|
type is GraphQLList<GraphQLType> | True when the value is a list type. |
assertListType()
Returns the value as a GraphQLList, or throws if it is not one.
Signature:
assertListType(type: unknown): GraphQLList<GraphQLType>
Arguments
| Name | Type | Description |
|---|---|---|
| type | unknown | The GraphQL type to inspect. |
Returns
| Type | Description |
|---|---|
GraphQLList<GraphQLType> | The value typed as a GraphQLList. |
Example
import { assertListType, GraphQLString } from 'graphql/type';
const type = assertListType(GraphQLString);
// type: GraphQLStringisNonNullType()
Overload 1
Returns true when the value is a GraphQLNonNull.
Signature:
isNonNullType(type: GraphQLInputType): type is GraphQLNonNull<GraphQLInputType>
Arguments
| Name | Type | Description |
|---|---|---|
| type | GraphQLInputType | The GraphQL type to inspect. |
Returns
| Type | Description |
|---|---|
type is GraphQLNonNull<GraphQLInputType> | True when the value matches this type. |
Example
import { GraphQLNonNull, GraphQLString, isNonNullType } from 'graphql/type';
isNonNullType(new GraphQLNonNull(GraphQLString));
// trueOverload 2
Returns true when the output type is a GraphQLNonNull.
Signature:
isNonNullType(type: GraphQLOutputType): type is GraphQLNonNull<GraphQLOutputType>
Arguments
| Name | Type | Description |
|---|---|---|
| type | GraphQLOutputType | The GraphQL output type to inspect. |
Returns
| Type | Description |
|---|---|
type is GraphQLNonNull<GraphQLOutputType> | True when the output type is a non-null type. |
Overload 3
Returns true when the value is a GraphQLNonNull.
Signature:
isNonNullType(type: unknown): type is GraphQLNonNull<GraphQLType>
Arguments
| Name | Type | Description |
|---|---|---|
| type | unknown | The value to inspect. |
Returns
| Type | Description |
|---|---|
type is GraphQLNonNull<GraphQLType> | True when the value is a non-null type. |
assertNonNullType()
Returns the value as a GraphQLNonNull, or throws if it is not one.
Signature:
assertNonNullType(type: unknown): GraphQLNonNull<GraphQLType>
Arguments
| Name | Type | Description |
|---|---|---|
| type | unknown | The GraphQL type to inspect. |
Returns
| Type | Description |
|---|---|
GraphQLNonNull<GraphQLType> | The value typed as a GraphQLNonNull. |
Example
import { assertNonNullType, GraphQLString } from 'graphql/type';
const type = assertNonNullType(GraphQLString);
// type: GraphQLStringisInputType()
Returns true when the value can be used as a GraphQL input type.
Signature:
isInputType(type: unknown): type is GraphQLInputType
Arguments
| Name | Type | Description |
|---|---|---|
| type | unknown | The GraphQL type to inspect. |
Returns
| Type | Description |
|---|---|
type is GraphQLInputType | True when the value matches this type. |
Example
import { isInputType, GraphQLString } from 'graphql/type';
const result = isInputType(GraphQLString);
// result: true for matching GraphQL typesassertInputType()
Returns the value as a GraphQL input type, or throws if it is not one.
Signature:
assertInputType(type: unknown): GraphQLInputType
Arguments
| Name | Type | Description |
|---|---|---|
| type | unknown | The GraphQL type to inspect. |
Returns
| Type | Description |
|---|---|
GraphQLInputType | The value typed as a GraphQL input type. |
Example
import { assertInputType, GraphQLString } from 'graphql/type';
const type = assertInputType(GraphQLString);
// type: GraphQLStringisOutputType()
Returns true when the value can be used as a GraphQL output type.
Signature:
isOutputType(type: unknown): type is GraphQLOutputType
Arguments
| Name | Type | Description |
|---|---|---|
| type | unknown | The GraphQL type to inspect. |
Returns
| Type | Description |
|---|---|
type is GraphQLOutputType | True when the value matches this type. |
Example
import { isOutputType, GraphQLString } from 'graphql/type';
const result = isOutputType(GraphQLString);
// result: true for matching GraphQL typesassertOutputType()
Returns the value as a GraphQL output type, or throws if it is not one.
Signature:
assertOutputType(type: unknown): GraphQLOutputType
Arguments
| Name | Type | Description |
|---|---|---|
| type | unknown | The GraphQL type to inspect. |
Returns
| Type | Description |
|---|---|
GraphQLOutputType | The value typed as a GraphQL output type. |
Example
import { assertOutputType, GraphQLString } from 'graphql/type';
const type = assertOutputType(GraphQLString);
// type: GraphQLStringisLeafType()
Returns true when the value is a GraphQL scalar or enum type.
Signature:
isLeafType(type: unknown): type is GraphQLLeafType
Arguments
| Name | Type | Description |
|---|---|---|
| type | unknown | The GraphQL type to inspect. |
Returns
| Type | Description |
|---|---|
type is GraphQLLeafType | True when the value matches this type. |
Example
import { isLeafType, GraphQLString } from 'graphql/type';
const result = isLeafType(GraphQLString);
// result: true for matching GraphQL typesassertLeafType()
Returns the value as a GraphQL leaf type, or throws if it is not one.
Signature:
assertLeafType(type: unknown): GraphQLLeafType
Arguments
| Name | Type | Description |
|---|---|---|
| type | unknown | The GraphQL type to inspect. |
Returns
| Type | Description |
|---|---|
GraphQLLeafType | The value typed as a GraphQL leaf type. |
Example
import { assertLeafType, GraphQLString } from 'graphql/type';
const type = assertLeafType(GraphQLString);
// type: GraphQLStringisCompositeType()
Returns true when the value is a GraphQL object, interface, or union type.
Signature:
isCompositeType(type: unknown): type is GraphQLCompositeType
Arguments
| Name | Type | Description |
|---|---|---|
| type | unknown | The GraphQL type to inspect. |
Returns
| Type | Description |
|---|---|
type is GraphQLCompositeType | True when the value matches this type. |
Example
import { isCompositeType, GraphQLString } from 'graphql/type';
const result = isCompositeType(GraphQLString);
// result: true for matching GraphQL typesassertCompositeType()
Returns the value as a GraphQL composite type, or throws if it is not one.
Signature:
assertCompositeType(type: unknown): GraphQLCompositeType
Arguments
| Name | Type | Description |
|---|---|---|
| type | unknown | The GraphQL type to inspect. |
Returns
| Type | Description |
|---|---|
GraphQLCompositeType | The value typed as a GraphQL composite type. |
Example
import { assertCompositeType, GraphQLString } from 'graphql/type';
const type = assertCompositeType(GraphQLString);
// type: GraphQLStringisAbstractType()
Returns true when the value is a GraphQL interface or union type.
Signature:
isAbstractType(type: unknown): type is GraphQLAbstractType
Arguments
| Name | Type | Description |
|---|---|---|
| type | unknown | The GraphQL type to inspect. |
Returns
| Type | Description |
|---|---|
type is GraphQLAbstractType | True when the value matches this type. |
Example
import { isAbstractType, GraphQLString } from 'graphql/type';
const result = isAbstractType(GraphQLString);
// result: true for matching GraphQL typesassertAbstractType()
Returns the value as a GraphQL abstract type, or throws if it is not one.
Signature:
assertAbstractType(type: unknown): GraphQLAbstractType
Arguments
| Name | Type | Description |
|---|---|---|
| type | unknown | The GraphQL type to inspect. |
Returns
| Type | Description |
|---|---|
GraphQLAbstractType | The value typed as a GraphQL abstract type. |
Example
import { assertAbstractType, GraphQLString } from 'graphql/type';
const type = assertAbstractType(GraphQLString);
// type: GraphQLStringisWrappingType()
Returns true when the value is a GraphQL list or non-null wrapper type.
Signature:
isWrappingType(type: unknown): type is GraphQLWrappingType
Arguments
| Name | Type | Description |
|---|---|---|
| type | unknown | The GraphQL type to inspect. |
Returns
| Type | Description |
|---|---|
type is GraphQLWrappingType | True when the value matches this type. |
Example
import { isWrappingType, GraphQLString } from 'graphql/type';
const result = isWrappingType(GraphQLString);
// result: true for matching GraphQL typesassertWrappingType()
Returns the value as a GraphQL wrapping type, or throws if it is not one.
Signature:
assertWrappingType(type: unknown): GraphQLWrappingType
Arguments
| Name | Type | Description |
|---|---|---|
| type | unknown | The GraphQL type to inspect. |
Returns
| Type | Description |
|---|---|
GraphQLWrappingType | The value typed as a GraphQL wrapping type. |
Example
import { assertWrappingType, GraphQLString } from 'graphql/type';
const type = assertWrappingType(GraphQLString);
// type: GraphQLStringisNullableType()
Returns true when the value is a GraphQL type that can accept null.
Signature:
isNullableType(type: unknown): type is GraphQLNullableType
Arguments
| Name | Type | Description |
|---|---|---|
| type | unknown | The GraphQL type to inspect. |
Returns
| Type | Description |
|---|---|
type is GraphQLNullableType | True when the value matches this type. |
Example
import { isNullableType, GraphQLString } from 'graphql/type';
const result = isNullableType(GraphQLString);
// result: true for matching GraphQL typesassertNullableType()
Returns the value as a nullable GraphQL type, or throws if it is not one.
Signature:
assertNullableType(type: unknown): GraphQLNullableType
Arguments
| Name | Type | Description |
|---|---|---|
| type | unknown | The GraphQL type to inspect. |
Returns
| Type | Description |
|---|---|
GraphQLNullableType | The value typed as a nullable GraphQL type. |
Example
import { assertNullableType, GraphQLString } from 'graphql/type';
const type = assertNullableType(GraphQLString);
// type: GraphQLStringgetNullableType()
Overload 1
Returns the nullable type.
Signature:
getNullableType(type: null | undefined): void
Arguments
| Name | Type | Description |
|---|---|---|
| type | null | undefined | The GraphQL type to inspect. |
Example
import { getNullableType } from 'graphql/type';
getNullableType(null);
// undefinedOverload 2
Returns the nullable type after removing one non-null wrapper.
Type Parameters
| Name | Constraint | Default | Description |
|---|---|---|---|
| T | GraphQLNullableType | The nullable GraphQL type returned after removing one non-null wrapper. |
Signature:
getNullableType<T extends GraphQLNullableType>(type: T | GraphQLNonNull<T>): T
Arguments
| Name | Type | Description |
|---|---|---|
| type | T | GraphQLNonNull<T> | A nullable type or non-null wrapper. |
Returns
| Type | Description |
|---|---|
T | The nullable type after removing one non-null wrapper, if present. |
Overload 3
Returns the nullable type after removing one non-null wrapper.
Signature:
getNullableType(type: null | undefined | GraphQLType): GraphQLNullableType | undefined
Arguments
| Name | Type | Description |
|---|---|---|
| type | null | undefined | GraphQLType | The GraphQL type to inspect. |
Returns
| Type | Description |
|---|---|
GraphQLNullableType | undefined | The nullable type after removing one non-null wrapper, if present. |
isNamedType()
Returns true when the value is a GraphQL named type.
Signature:
isNamedType(type: unknown): type is GraphQLNamedType
Arguments
| Name | Type | Description |
|---|---|---|
| type | unknown | The GraphQL type to inspect. |
Returns
| Type | Description |
|---|---|
type is GraphQLNamedType | True when the value matches this type. |
Example
import { isNamedType, GraphQLString } from 'graphql/type';
const result = isNamedType(GraphQLString);
// result: true for matching GraphQL typesassertNamedType()
Returns the value as a GraphQL named type, or throws if it is not one.
Signature:
assertNamedType(type: unknown): GraphQLNamedType
Arguments
| Name | Type | Description |
|---|---|---|
| type | unknown | The GraphQL type to inspect. |
Returns
| Type | Description |
|---|---|
GraphQLNamedType | The value typed as a GraphQL named type. |
Example
import { assertNamedType, GraphQLString } from 'graphql/type';
const type = assertNamedType(GraphQLString);
// type: GraphQLStringgetNamedType()
Overload 1
Returns the named type.
Signature:
getNamedType(type: null | undefined): void
Arguments
| Name | Type | Description |
|---|---|---|
| type | null | undefined | The GraphQL type to inspect. |
Example
import { getNamedType } from 'graphql/type';
getNamedType(null);
// undefinedOverload 2
Returns the named input type after unwrapping all list and non-null wrappers.
Signature:
getNamedType(type: GraphQLInputType): GraphQLNamedInputType
Arguments
| Name | Type | Description |
|---|---|---|
| type | GraphQLInputType | The GraphQL input type to inspect. |
Returns
| Type | Description |
|---|---|
GraphQLNamedInputType | The named input type after unwrapping all wrappers. |
Overload 3
Returns the named output type after unwrapping all list and non-null wrappers.
Signature:
getNamedType(type: GraphQLOutputType): GraphQLNamedOutputType
Arguments
| Name | Type | Description |
|---|---|---|
| type | GraphQLOutputType | The GraphQL output type to inspect. |
Returns
| Type | Description |
|---|---|
GraphQLNamedOutputType | The named output type after unwrapping all wrappers. |
Overload 4
Returns the named type after unwrapping all list and non-null wrappers.
Signature:
getNamedType(type: GraphQLType): GraphQLNamedType
Arguments
| Name | Type | Description |
|---|---|---|
| type | GraphQLType | The GraphQL type to inspect. |
Returns
| Type | Description |
|---|---|
GraphQLNamedType | The named type after unwrapping all wrappers. |
Overload 5
Returns the named type after unwrapping all list and non-null wrappers.
Signature:
getNamedType(type: null | undefined | GraphQLType): GraphQLNamedType | undefined
Arguments
| Name | Type | Description |
|---|---|---|
| type | null | undefined | GraphQLType | The GraphQL type to inspect. |
Returns
| Type | Description |
|---|---|
GraphQLNamedType | undefined | The named type after unwrapping all wrappers, or undefined for nullish input. |
resolveReadonlyArrayThunk()
Resolves a thunked readonly array.
Type Parameters
| Name | Constraint | Default | Description |
|---|---|---|---|
| T | The element type resolved from the thunk or array. |
Signature:
resolveReadonlyArrayThunk<T>(thunk: ThunkReadonlyArray<T>): readonly T[]
Arguments
| Name | Type | Description |
|---|---|---|
| thunk | ThunkReadonlyArray<T> | The thunk or value to resolve. |
Returns
| Type | Description |
|---|---|
readonly T[] | The resolved readonly array. |
Example
import { GraphQLString, resolveReadonlyArrayThunk } from 'graphql/type';
const fields = resolveReadonlyArrayThunk(() => [GraphQLString]);
// fields: [GraphQLString]resolveObjMapThunk()
Resolves a thunked object map.
Type Parameters
| Name | Constraint | Default | Description |
|---|---|---|---|
| T | The object-map value type resolved from the thunk or map. |
Signature:
resolveObjMapThunk<T>(thunk: ThunkObjMap<T>): object
Arguments
| Name | Type | Description |
|---|---|---|
| thunk | ThunkObjMap<T> | The thunk or value to resolve. |
Returns
| Type | Description |
|---|---|
object | The resolved object map. |
Example
import { GraphQLString, resolveObjMapThunk } from 'graphql/type';
const fields = resolveObjMapThunk(() => ({ name: GraphQLString }));
// fields.name: GraphQLStringisRequiredArgument()
Returns true when the argument is non-null and has no default value.
Signature:
isRequiredArgument(arg: GraphQLArgument): boolean
Arguments
| Name | Type | Description |
|---|---|---|
| arg | GraphQLArgument | The argument definition to inspect. |
Returns
| Type | Description |
|---|---|
boolean | True when the value matches this type. |
Example
import { isRequiredArgument, GraphQLString } from 'graphql/type';
const result = isRequiredArgument(GraphQLString);
// result: true for matching GraphQL typesisRequiredInputField()
Returns true when the input field is non-null and has no default value.
Signature:
isRequiredInputField(field: GraphQLInputField): boolean
Arguments
| Name | Type | Description |
|---|---|---|
| field | GraphQLInputField | The input field definition to inspect. |
Returns
| Type | Description |
|---|---|
boolean | True when the value matches this type. |
Example
import { isRequiredInputField, GraphQLString } from 'graphql/type';
const result = isRequiredInputField(GraphQLString);
// result: true for matching GraphQL typesTypes
GraphQLType
Type alias. These are all of the possible kinds of types.
type GraphQLType = GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | GraphQLUnionType | GraphQLEnumType | GraphQLInputObjectType | GraphQLList<GraphQLType> | GraphQLNonNull<GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | GraphQLUnionType | GraphQLEnumType | GraphQLInputObjectType | GraphQLList<GraphQLType>>;
GraphQLInputType
Type alias. These types may be used as input types for arguments and directives.
type GraphQLInputType = GraphQLScalarType | GraphQLEnumType | GraphQLInputObjectType | GraphQLList<GraphQLInputType> | GraphQLNonNull<GraphQLScalarType | GraphQLEnumType | GraphQLInputObjectType | GraphQLList<GraphQLInputType>>;
GraphQLOutputType
Type alias. These types may be used as output types as the result of fields.
type GraphQLOutputType = GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | GraphQLUnionType | GraphQLEnumType | GraphQLList<GraphQLOutputType> | GraphQLNonNull<GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | GraphQLUnionType | GraphQLEnumType | GraphQLList<GraphQLOutputType>>;
GraphQLLeafType
Type alias. These types may describe types which may be leaf values.
type GraphQLLeafType = GraphQLScalarType | GraphQLEnumType;
GraphQLCompositeType
Type alias. These types may describe the parent context of a selection set.
type GraphQLCompositeType = GraphQLObjectType | GraphQLInterfaceType | GraphQLUnionType;
GraphQLAbstractType
Type alias. These types may describe the parent context of a selection set.
type GraphQLAbstractType = GraphQLInterfaceType | GraphQLUnionType;
GraphQLWrappingType
Type alias. These types wrap and modify other types
type GraphQLWrappingType = GraphQLList<GraphQLType> | GraphQLNonNull<GraphQLType>;
GraphQLNullableType
Type alias. These types can all accept null as a value.
type GraphQLNullableType = GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | GraphQLUnionType | GraphQLEnumType | GraphQLInputObjectType | GraphQLList<GraphQLType>;
GraphQLNamedType
Type alias. These named types do not include modifiers like List or NonNull.
type GraphQLNamedType = GraphQLNamedInputType | GraphQLNamedOutputType;
GraphQLNamedInputType
Type alias. A named GraphQL type that can be used as an input type.
type GraphQLNamedInputType = GraphQLScalarType | GraphQLEnumType | GraphQLInputObjectType;
GraphQLNamedOutputType
Type alias. A named GraphQL type that can be used as an output type.
type GraphQLNamedOutputType = GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | GraphQLUnionType | GraphQLEnumType;
ThunkReadonlyArray
Type alias. Used while defining GraphQL types to allow for circular references in otherwise immutable type definitions.
Type Parameters
| Name | Constraint | Default | Description |
|---|---|---|---|
| T | The element type returned by the thunk or array. |
type ThunkReadonlyArray<T> = (): ReadonlyArray<T> | ReadonlyArray<T>;
ThunkObjMap
Type alias. A thunk that resolves to an object map.
Type Parameters
| Name | Constraint | Default | Description |
|---|---|---|---|
| T | The value type stored in the object map. |
type ThunkObjMap<T> = (): object | object;
GraphQLScalarTypeExtensions
Interface. Custom extensions
Remarks: Use a unique identifier name for your extension, for example the name of your library or project. Do not use a shortened identifier as this increases the risk of conflicts. We recommend you add at most one extension field, an object which can contain all the values you need.
GraphQLScalarSerializer
Type alias. Serializes a runtime value as a scalar output value.
Type Parameters
| Name | Constraint | Default | Description |
|---|---|---|---|
| TExternal | The serialized representation returned for GraphQL results. |
type GraphQLScalarSerializer<TExternal> = (outputValue: unknown): TExternal;
GraphQLScalarValueParser
Type alias. Parses a runtime input value as a scalar input value.
Type Parameters
| Name | Constraint | Default | Description |
|---|---|---|---|
| TInternal | The internal runtime representation produced from variable input. |
type GraphQLScalarValueParser<TInternal> = (inputValue: unknown): TInternal;
GraphQLScalarLiteralParser
Type alias. Parses a GraphQL value literal as a scalar input value.
Type Parameters
| Name | Constraint | Default | Description |
|---|---|---|---|
| TInternal | The internal runtime representation produced from literal input. |
type GraphQLScalarLiteralParser<TInternal> = (valueNode: ValueNode, variables?: null | undefined | object): TInternal;
GraphQLScalarTypeConfig
Interface. Configuration used to construct a GraphQLScalarType.
Type Parameters
| Name | Constraint | Default | Description |
|---|---|---|---|
| TInternal | The internal runtime representation accepted by this scalar. | ||
| TExternal | The serialized representation exposed in GraphQL results. |
Members
| Name | Type | Description |
|---|---|---|
| name | string | The GraphQL name for this schema element. |
| description? | null | undefined | string | Human-readable description for this schema element, if provided. |
| specifiedByURL? | null | undefined | string | URL identifying the behavior specified for this custom scalar. |
| serialize? | GraphQLScalarSerializer<TExternal> | Serializes an internal value to include in a response. |
| parseValue? | GraphQLScalarValueParser<TInternal> | Parses an externally provided value to use as an input. |
| parseLiteral? | GraphQLScalarLiteralParser<TInternal> | Parses an externally provided literal value to use as an input. |
| extensions? | null | undefined | Readonly<GraphQLScalarTypeExtensions> | Extension fields to include in the formatted result. |
| astNode? | null | undefined | ScalarTypeDefinitionNode | AST node from which this schema element was built, if available. |
| extensionASTNodes? | null | undefined | readonly ScalarTypeExtensionNode[] | AST extension nodes applied to this schema element. |
GraphQLObjectTypeExtensions
Interface. Custom extensions
Remarks: Use a unique identifier name for your extension, for example the name of your library or project. Do not use a shortened identifier as this increases the risk of conflicts. We recommend you add at most one extension field, an object which can contain all the values you need.
We’ve provided these template arguments because this is an open type and you may find them useful.
Type Parameters
| Name | Constraint | Default | Description |
|---|---|---|---|
| _TSource | any | The JavaScript source value type associated with this object type. | |
| _TContext | any | The application context type passed to resolvers for this object type. |
GraphQLObjectTypeConfig
Interface. Configuration used to construct a GraphQLObjectType.
Type Parameters
| Name | Constraint | Default | Description |
|---|---|---|---|
| TSource | The JavaScript source value type resolved as this object type. | ||
| TContext | The application context type passed to this object type’s resolvers. |
Members
| Name | Type | Description |
|---|---|---|
| name | string | The GraphQL name for this schema element. |
| description? | null | undefined | string | Human-readable description for this schema element, if provided. |
| interfaces? | ThunkReadonlyArray<GraphQLInterfaceType> | Interfaces implemented by this object or interface type. |
| fields | ThunkObjMap<GraphQLFieldConfig<TSource, TContext>> | Fields declared by this object, interface, input object, or literal. |
| isTypeOf? | null | undefined | GraphQLIsTypeOfFn<TSource, TContext> | Predicate used to determine whether a runtime value belongs to this object type. |
| extensions? | null | undefined | Readonly<GraphQLObjectTypeExtensions<TSource, TContext>> | Extension fields to include in the formatted result. |
| astNode? | null | undefined | ObjectTypeDefinitionNode | AST node from which this schema element was built, if available. |
| extensionASTNodes? | null | undefined | readonly ObjectTypeExtensionNode[] | AST extension nodes applied to this schema element. |
GraphQLTypeResolver
Type alias. Resolves the concrete object type for an abstract GraphQL type.
Type Parameters
| Name | Constraint | Default | Description |
|---|---|---|---|
| TSource | The JavaScript source value being resolved to a concrete object type. | ||
| TContext | The application context type passed to the type resolver. |
type GraphQLTypeResolver<TSource, TContext> = (value: TSource, context: TContext, info: GraphQLResolveInfo, abstractType: GraphQLAbstractType): Promise<string | undefined> | string | undefined;
GraphQLIsTypeOfFn
Type alias. Checks whether a runtime value belongs to a GraphQL object type.
Type Parameters
| Name | Constraint | Default | Description |
|---|---|---|---|
| TSource | The JavaScript source value tested against this object type. | ||
| TContext | The application context type passed to the predicate. |
type GraphQLIsTypeOfFn<TSource, TContext> = (source: TSource, context: TContext, info: GraphQLResolveInfo): Promise<boolean> | boolean;
GraphQLFieldResolver
Type alias. Resolves the runtime value for a GraphQL field.
Type Parameters
| Name | Constraint | Default | Description |
|---|---|---|---|
| TSource | The JavaScript source value passed to the field resolver. | ||
| TContext | The application context type passed to the field resolver. | ||
| TArgs | any | The field argument map type passed to the field resolver. | |
| TResult | unknown | The runtime value returned by the field resolver. |
type GraphQLFieldResolver<TSource, TContext, TArgs = any, TResult = unknown> = (source: TSource, args: TArgs, context: TContext, info: GraphQLResolveInfo): TResult;
GraphQLResolveInfo
Interface. Information about the currently executing GraphQL field.
Members
| Name | Type | Description |
|---|---|---|
| fieldName | string | The field name referenced by this schema coordinate. |
| fieldNodes | readonly FieldNode[] | AST field nodes that contributed to the current field execution. |
| returnType | GraphQLOutputType | GraphQL output type declared for the current field. |
| parentType | GraphQLObjectType | Object type that owns the current field. |
| path | Path | Response path where this error occurred during execution. |
| schema | GraphQLSchema | The schema used for validation or execution. |
| fragments | object | Fragment definitions in the operation document keyed by fragment name. |
| rootValue | unknown | Initial root value passed to the operation. |
| operation | OperationDefinitionNode | The operation selected for execution. |
| variableValues | object | Runtime variable values keyed by variable name. |
GraphQLFieldExtensions
Interface. Custom extensions
Remarks: Use a unique identifier name for your extension, for example the name of your library or project. Do not use a shortened identifier as this increases the risk of conflicts. We recommend you add at most one extension field, an object which can contain all the values you need.
We’ve provided these template arguments because this is an open type and you may find them useful.
Type Parameters
| Name | Constraint | Default | Description |
|---|---|---|---|
| _TSource | The JavaScript source value type associated with this field. | ||
| _TContext | The application context type associated with this field. | ||
| _TArgs | any | The field argument map type associated with this field. |
GraphQLFieldConfig
Interface. Configuration used to define a GraphQL field.
Type Parameters
| Name | Constraint | Default | Description |
|---|---|---|---|
| TSource | The JavaScript source value type passed to this field’s resolver. | ||
| TContext | The application context type passed to this field’s resolver. | ||
| TArgs | any | The field argument map type passed to this field’s resolver. |
Members
| Name | Type | Description |
|---|---|---|
| description? | null | undefined | string | Human-readable description for this schema element, if provided. |
| type | GraphQLOutputType | The GraphQL type reference or runtime type for this element. |
| args? | GraphQLFieldConfigArgumentMap | Arguments accepted by this field or directive. |
| resolve? | GraphQLFieldResolver<TSource, TContext, TArgs> | Resolver function used to produce this field value. |
| subscribe? | GraphQLFieldResolver<TSource, TContext, TArgs> | Resolver function used to create a subscription event stream for this field. |
| deprecationReason? | null | undefined | string | Reason this element is deprecated, if one was provided. |
| extensions? | null | undefined | Readonly<GraphQLFieldExtensions<TSource, TContext, TArgs>> | Extension fields to include in the formatted result. |
| astNode? | null | undefined | FieldDefinitionNode | AST node from which this schema element was built, if available. |
GraphQLFieldConfigArgumentMap
Type alias. A map of argument names to argument configuration objects.
type GraphQLFieldConfigArgumentMap = object;
GraphQLArgumentExtensions
Interface. Custom extensions
Remarks: Use a unique identifier name for your extension, for example the name of your library or project. Do not use a shortened identifier as this increases the risk of conflicts. We recommend you add at most one extension field, an object which can contain all the values you need.
GraphQLArgumentConfig
Interface. Configuration used to define a GraphQL argument.
Members
| Name | Type | Description |
|---|---|---|
| description? | null | undefined | string | Human-readable description for this schema element, if provided. |
| type | GraphQLInputType | The GraphQL type reference or runtime type for this element. |
| defaultValue? | unknown | The default value used when no explicit value is supplied. |
| deprecationReason? | null | undefined | string | Reason this element is deprecated, if one was provided. |
| extensions? | null | undefined | Readonly<GraphQLArgumentExtensions> | Extension fields to include in the formatted result. |
| astNode? | null | undefined | InputValueDefinitionNode | AST node from which this schema element was built, if available. |
GraphQLFieldConfigMap
Type alias. A map of field names to field configuration objects.
Type Parameters
| Name | Constraint | Default | Description |
|---|---|---|---|
| TSource | The JavaScript source value type for fields in this map. | ||
| TContext | The application context type for fields in this map. |
type GraphQLFieldConfigMap<TSource, TContext> = object;
GraphQLField
Interface. A resolved GraphQL field definition.
Type Parameters
| Name | Constraint | Default | Description |
|---|---|---|---|
| TSource | The JavaScript source value type passed to this field’s resolver. | ||
| TContext | The application context type passed to this field’s resolver. | ||
| TArgs | any | The field argument map type passed to this field’s resolver. |
Members
| Name | Type | Description |
|---|---|---|
| name | string | The GraphQL name for this schema element. |
| description | null | undefined | string | Human-readable description for this schema element, if provided. |
| type | GraphQLOutputType | The GraphQL type reference or runtime type for this element. |
| args | readonly GraphQLArgument[] | Arguments accepted by this field or directive. |
| resolve? | GraphQLFieldResolver<TSource, TContext, TArgs> | Resolver function used to produce this field value. |
| subscribe? | GraphQLFieldResolver<TSource, TContext, TArgs> | Resolver function used to create a subscription event stream for this field. |
| deprecationReason | null | undefined | string | Reason this element is deprecated, if one was provided. |
| extensions | Readonly<GraphQLFieldExtensions<TSource, TContext, TArgs>> | Extension fields to include in the formatted result. |
| astNode | null | undefined | FieldDefinitionNode | AST node from which this schema element was built, if available. |
GraphQLArgument
Interface. A resolved GraphQL argument definition.
Members
| Name | Type | Description |
|---|---|---|
| name | string | The GraphQL name for this schema element. |
| description | null | undefined | string | Human-readable description for this schema element, if provided. |
| type | GraphQLInputType | The GraphQL type reference or runtime type for this element. |
| defaultValue | unknown | The default value used when no explicit value is supplied. |
| deprecationReason | null | undefined | string | Reason this element is deprecated, if one was provided. |
| extensions | Readonly<GraphQLArgumentExtensions> | Extension fields to include in the formatted result. |
| astNode | null | undefined | InputValueDefinitionNode | AST node from which this schema element was built, if available. |
GraphQLFieldMap
Type alias. A map of field names to resolved field definitions.
Type Parameters
| Name | Constraint | Default | Description |
|---|---|---|---|
| TSource | The JavaScript source value type for resolved fields in this map. | ||
| TContext | The application context type for resolved fields in this map. |
type GraphQLFieldMap<TSource, TContext> = object;
GraphQLInterfaceTypeExtensions
Interface. Custom extensions
Remarks: Use a unique identifier name for your extension, for example the name of your library or project. Do not use a shortened identifier as this increases the risk of conflicts. We recommend you add at most one extension field, an object which can contain all the values you need.
GraphQLInterfaceTypeConfig
Interface. Configuration used to construct a GraphQLInterfaceType.
Type Parameters
| Name | Constraint | Default | Description |
|---|---|---|---|
| TSource | The JavaScript source value type resolved as an implementing object type. | ||
| TContext | The application context type passed to this interface type’s resolvers. |
Members
| Name | Type | Description |
|---|---|---|
| name | string | The GraphQL name for this schema element. |
| description? | null | undefined | string | Human-readable description for this schema element, if provided. |
| interfaces? | ThunkReadonlyArray<GraphQLInterfaceType> | Interfaces implemented by this object or interface type. |
| fields | ThunkObjMap<GraphQLFieldConfig<TSource, TContext>> | Fields declared by this object, interface, input object, or literal. |
| resolveType? | null | undefined | GraphQLTypeResolver<TSource, TContext> | Optionally provide a custom type resolver function. If one is not provided, the default implementation will call isTypeOf on each implementingObject type. |
| extensions? | null | undefined | Readonly<GraphQLInterfaceTypeExtensions> | Extension fields to include in the formatted result. |
| astNode? | null | undefined | InterfaceTypeDefinitionNode | AST node from which this schema element was built, if available. |
| extensionASTNodes? | null | undefined | readonly InterfaceTypeExtensionNode[] | AST extension nodes applied to this schema element. |
GraphQLUnionTypeExtensions
Interface. Custom extensions
Remarks: Use a unique identifier name for your extension, for example the name of your library or project. Do not use a shortened identifier as this increases the risk of conflicts. We recommend you add at most one extension field, an object which can contain all the values you need.
GraphQLUnionTypeConfig
Interface. Configuration used to construct a GraphQLUnionType.
Type Parameters
| Name | Constraint | Default | Description |
|---|---|---|---|
| TSource | The JavaScript source value type resolved as a union member. | ||
| TContext | The application context type passed to this union type’s resolver. |
Members
| Name | Type | Description |
|---|---|---|
| name | string | The GraphQL name for this schema element. |
| description? | null | undefined | string | Human-readable description for this schema element, if provided. |
| types | ThunkReadonlyArray<GraphQLObjectType> | Object types that belong to this union type. |
| resolveType? | null | undefined | GraphQLTypeResolver<TSource, TContext> | Optionally provide a custom type resolver function. If one is not provided, the default implementation will call isTypeOf on each implementingObject type. |
| extensions? | null | undefined | Readonly<GraphQLUnionTypeExtensions> | Extension fields to include in the formatted result. |
| astNode? | null | undefined | UnionTypeDefinitionNode | AST node from which this schema element was built, if available. |
| extensionASTNodes? | null | undefined | readonly UnionTypeExtensionNode[] | AST extension nodes applied to this schema element. |
GraphQLEnumTypeExtensions
Interface. Custom extensions
Remarks: Use a unique identifier name for your extension, for example the name of your library or project. Do not use a shortened identifier as this increases the risk of conflicts. We recommend you add at most one extension field, an object which can contain all the values you need.
GraphQLEnumTypeConfig
Interface. Configuration used to construct a GraphQLEnumType.
Members
| Name | Type | Description |
|---|---|---|
| name | string | The GraphQL name for this schema element. |
| description? | null | undefined | string | Human-readable description for this schema element, if provided. |
| values | ThunkObjMap<GraphQLEnumValueConfig> | Values contained in this enum, list, or input-object definition. |
| extensions? | null | undefined | Readonly<GraphQLEnumTypeExtensions> | Extension fields to include in the formatted result. |
| astNode? | null | undefined | EnumTypeDefinitionNode | AST node from which this schema element was built, if available. |
| extensionASTNodes? | null | undefined | readonly EnumTypeExtensionNode[] | AST extension nodes applied to this schema element. |
GraphQLEnumValueConfigMap
Type alias. A map of enum value names to enum value configuration objects.
type GraphQLEnumValueConfigMap = object;
GraphQLEnumValueExtensions
Interface. Custom extensions
Remarks: Use a unique identifier name for your extension, for example the name of your library or project. Do not use a shortened identifier as this increases the risk of conflicts. We recommend you add at most one extension field, an object which can contain all the values you need.
GraphQLEnumValueConfig
Interface. Configuration used to define a GraphQL enum value.
Members
| Name | Type | Description |
|---|---|---|
| description? | null | undefined | string | Human-readable description for this schema element, if provided. |
| value? | any | The parsed value represented by this node. |
| deprecationReason? | null | undefined | string | Reason this element is deprecated, if one was provided. |
| extensions? | null | undefined | Readonly<GraphQLEnumValueExtensions> | Extension fields to include in the formatted result. |
| astNode? | null | undefined | EnumValueDefinitionNode | AST node from which this schema element was built, if available. |
GraphQLEnumValue
Interface. A resolved GraphQL enum value definition.
Members
| Name | Type | Description |
|---|---|---|
| name | string | The GraphQL name for this schema element. |
| description | null | undefined | string | Human-readable description for this schema element, if provided. |
| value | any | The parsed value represented by this node. |
| deprecationReason | null | undefined | string | Reason this element is deprecated, if one was provided. |
| extensions | Readonly<GraphQLEnumValueExtensions> | Extension fields to include in the formatted result. |
| astNode | null | undefined | EnumValueDefinitionNode | AST node from which this schema element was built, if available. |
GraphQLInputObjectTypeExtensions
Interface. Custom extensions
Remarks: Use a unique identifier name for your extension, for example the name of your library or project. Do not use a shortened identifier as this increases the risk of conflicts. We recommend you add at most one extension field, an object which can contain all the values you need.
GraphQLInputObjectTypeConfig
Interface. Configuration used to construct a GraphQLInputObjectType.
Members
| Name | Type | Description |
|---|---|---|
| name | string | The GraphQL name for this schema element. |
| description? | null | undefined | string | Human-readable description for this schema element, if provided. |
| fields | ThunkObjMap<GraphQLInputFieldConfig> | Fields declared by this object, interface, input object, or literal. |
| extensions? | null | undefined | Readonly<GraphQLInputObjectTypeExtensions> | Extension fields to include in the formatted result. |
| astNode? | null | undefined | InputObjectTypeDefinitionNode | AST node from which this schema element was built, if available. |
| extensionASTNodes? | null | undefined | readonly InputObjectTypeExtensionNode[] | AST extension nodes applied to this schema element. |
| isOneOf? | boolean | Whether this input object uses the experimental OneOf input object semantics. |
GraphQLInputFieldExtensions
Interface. Custom extensions
Remarks: Use a unique identifier name for your extension, for example the name of your library or project. Do not use a shortened identifier as this increases the risk of conflicts. We recommend you add at most one extension field, an object which can contain all the values you need.
GraphQLInputFieldConfig
Interface. Configuration used to define a GraphQL input field.
Members
| Name | Type | Description |
|---|---|---|
| description? | null | undefined | string | Human-readable description for this schema element, if provided. |
| type | GraphQLInputType | The GraphQL type reference or runtime type for this element. |
| defaultValue? | unknown | The default value used when no explicit value is supplied. |
| deprecationReason? | null | undefined | string | Reason this element is deprecated, if one was provided. |
| extensions? | null | undefined | Readonly<GraphQLInputFieldExtensions> | Extension fields to include in the formatted result. |
| astNode? | null | undefined | InputValueDefinitionNode | AST node from which this schema element was built, if available. |
GraphQLInputFieldConfigMap
Type alias. A map of input field names to input field configuration objects.
type GraphQLInputFieldConfigMap = object;
GraphQLInputField
Interface. A resolved GraphQL input field definition.
Members
| Name | Type | Description |
|---|---|---|
| name | string | The GraphQL name for this schema element. |
| description | null | undefined | string | Human-readable description for this schema element, if provided. |
| type | GraphQLInputType | The GraphQL type reference or runtime type for this element. |
| defaultValue | unknown | The default value used when no explicit value is supplied. |
| deprecationReason | null | undefined | string | Reason this element is deprecated, if one was provided. |
| extensions | Readonly<GraphQLInputFieldExtensions> | Extension fields to include in the formatted result. |
| astNode | null | undefined | InputValueDefinitionNode | AST node from which this schema element was built, if available. |
GraphQLInputFieldMap
Type alias. A map of input field names to resolved input field definitions.
type GraphQLInputFieldMap = object;