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

NameConstraintDefaultDescription
TGraphQLTypeThe GraphQL type wrapped by this list type.

Constructor

Creates a GraphQLList instance.

Signature:

new GraphQLList(ofType: T)
Arguments
NameTypeDescription
ofTypeTThe type to wrap.
Returns
TypeDescription
GraphQLList<T>

Members

NameTypeDescription
ofTypeTThe type wrapped by this list or non-null type.

toString()

Returns this wrapping type as a GraphQL type-reference string.

Signature:

toString(): string
Returns
TypeDescription
stringThe 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
TypeDescription
stringThe JSON-serializable representation.
Example
const json = listType.toJSON();
 
// json: the JSON representation

GraphQLNonNull

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

NameConstraintDefaultDescription
TGraphQLNullableTypeThe nullable GraphQL type wrapped by this non-null type.

Constructor

Creates a GraphQLNonNull instance.

Signature:

new GraphQLNonNull(ofType: T)
Arguments
NameTypeDescription
ofTypeTThe type to wrap.
Returns
TypeDescription
GraphQLNonNull<T>

Members

NameTypeDescription
ofTypeTThe type wrapped by this list or non-null type.

toString()

Returns this wrapping type as a GraphQL type-reference string.

Signature:

toString(): string
Returns
TypeDescription
stringThe 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
TypeDescription
stringThe JSON-serializable representation.
Example
const json = nonNullType.toJSON();
 
// json: the JSON representation

GraphQLScalarType

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

NameConstraintDefaultDescription
TInternalunknownThe internal runtime representation accepted by this scalar.
TExternalTInternalThe serialized representation exposed in GraphQL results.

Constructor

Creates a GraphQLScalarType instance.

Signature:

new GraphQLScalarType(config: Readonly<GraphQLScalarTypeConfig<TInternal, TExternal>>)
Arguments
NameTypeDescription
configReadonly<GraphQLScalarTypeConfig<TInternal, TExternal>>Configuration describing this object.
Returns
TypeDescription
GraphQLScalarType<TInternal, TExternal>

Members

NameTypeDescription
namestringThe GraphQL name for this schema element.
descriptionnull | undefined | stringHuman-readable description for this schema element, if provided.
specifiedByURLnull | undefined | stringURL identifying the behavior specified for this custom scalar.
serializeGraphQLScalarSerializer<TExternal>Function that converts internal values to externally visible scalar values.
parseValueGraphQLScalarValueParser<TInternal>Function that converts variable input into this scalar’s internal value.
parseLiteralGraphQLScalarLiteralParser<TInternal>Function that converts AST input literals into this scalar’s internal value.
extensionsReadonly<GraphQLScalarTypeExtensions>Extension fields to include in the formatted result.
astNodenull | undefined | ScalarTypeDefinitionNodeAST node from which this schema element was built, if available.
extensionASTNodesreadonly 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
TypeDescription
{ 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 value

toString()

Returns the schema coordinate identifying this scalar type.

Signature:

toString(): string
Returns
TypeDescription
stringThe 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
TypeDescription
stringThe JSON-serializable representation.
Example
const json = scalarType.toJSON();
 
// json: the JSON representation

GraphQLObjectType

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

NameConstraintDefaultDescription
TSourceanyThe JavaScript source value type resolved as this object type.
TContextanyThe application context type passed to this object type’s resolvers.

Constructor

Creates a GraphQLObjectType instance.

Signature:

new GraphQLObjectType(config: Readonly<GraphQLObjectTypeConfig<TSource, TContext>>)
Arguments
NameTypeDescription
configReadonly<GraphQLObjectTypeConfig<TSource, TContext>>Configuration describing this object.
Returns
TypeDescription
GraphQLObjectType<TSource, TContext>

Members

NameTypeDescription
namestringThe GraphQL name for this schema element.
descriptionnull | undefined | stringHuman-readable description for this schema element, if provided.
isTypeOfnull | undefined | GraphQLIsTypeOfFn<TSource, TContext>Predicate used to determine whether a runtime value belongs to this object type.
extensionsReadonly<GraphQLObjectTypeExtensions<TSource, TContext>>Extension fields to include in the formatted result.
astNodenull | undefined | ObjectTypeDefinitionNodeAST node from which this schema element was built, if available.
extensionASTNodesreadonly ObjectTypeExtensionNode[]AST extension nodes applied to this schema element.

getFields()

Returns the fields defined by this type.

Signature:

getFields(): GraphQLFieldMap<TSource, TContext>
Returns
TypeDescription
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 value

getInterfaces()

Returns the interfaces implemented by this type.

Signature:

getInterfaces(): readonly GraphQLInterfaceType[]
Returns
TypeDescription
readonly GraphQLInterfaceType[]The implemented interfaces.
Example
// Given a GraphQLObjectType instance named objectType:
const result = objectType.getInterfaces();
 
// result contains the getInterfaces return value

toConfig()

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
TypeDescription
{ 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 value

toString()

Returns the schema coordinate identifying this object type.

Signature:

toString(): string
Returns
TypeDescription
stringThe 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
TypeDescription
stringThe JSON-serializable representation.
Example
const json = objectType.toJSON();
 
// json: the JSON representation

GraphQLInterfaceType

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
NameTypeDescription
configReadonly<GraphQLInterfaceTypeConfig<any, any>>Configuration describing this object.
Returns
TypeDescription
GraphQLInterfaceType

Members

NameTypeDescription
namestringThe GraphQL name for this schema element.
descriptionnull | undefined | stringHuman-readable description for this schema element, if provided.
resolveTypenull | undefined | GraphQLTypeResolver<any, any>Function that resolves the concrete object type for this abstract type.
extensionsReadonly<GraphQLInterfaceTypeExtensions>Extension fields to include in the formatted result.
astNodenull | undefined | InterfaceTypeDefinitionNodeAST node from which this schema element was built, if available.
extensionASTNodesreadonly InterfaceTypeExtensionNode[]AST extension nodes applied to this schema element.

getFields()

Returns the fields defined by this type.

Signature:

getFields(): GraphQLFieldMap<any, any>
Returns
TypeDescription
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 value

getInterfaces()

Returns the interfaces implemented by this type.

Signature:

getInterfaces(): readonly GraphQLInterfaceType[]
Returns
TypeDescription
readonly GraphQLInterfaceType[]The implemented interfaces.
Example
// Given a GraphQLInterfaceType instance named interfaceType:
const result = interfaceType.getInterfaces();
 
// result contains the getInterfaces return value

toConfig()

Returns a normalized configuration object for this object.

Signature:

toConfig(): { interfaces: ReadonlyArray<GraphQLInterfaceType>; fields: GraphQLFieldConfigMap<any, any>; extensions: Readonly<GraphQLInterfaceTypeExtensions>; extensionASTNodes: ReadonlyArray<InterfaceTypeExtensionNode> }
Returns
TypeDescription
{ 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 value

toString()

Returns the schema coordinate identifying this interface type.

Signature:

toString(): string
Returns
TypeDescription
stringThe 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
TypeDescription
stringThe JSON-serializable representation.
Example
const json = interfaceType.toJSON();
 
// json: the JSON representation

GraphQLUnionType

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
NameTypeDescription
configReadonly<GraphQLUnionTypeConfig<any, any>>Configuration describing this object.
Returns
TypeDescription
GraphQLUnionType

Members

NameTypeDescription
namestringThe GraphQL name for this schema element.
descriptionnull | undefined | stringHuman-readable description for this schema element, if provided.
resolveTypenull | undefined | GraphQLTypeResolver<any, any>Function that resolves the concrete object type for this abstract type.
extensionsReadonly<GraphQLUnionTypeExtensions>Extension fields to include in the formatted result.
astNodenull | undefined | UnionTypeDefinitionNodeAST node from which this schema element was built, if available.
extensionASTNodesreadonly UnionTypeExtensionNode[]AST extension nodes applied to this schema element.

getTypes()

Returns the object types included in this union.

Signature:

getTypes(): readonly GraphQLObjectType[]
Returns
TypeDescription
readonly GraphQLObjectType[]The union member object types.
Example
// Given a GraphQLUnionType instance named unionType:
const result = unionType.getTypes();
 
// result contains the getTypes return value

toConfig()

Returns a normalized configuration object for this object.

Signature:

toConfig(): { types: ReadonlyArray<GraphQLObjectType>; extensions: Readonly<GraphQLUnionTypeExtensions>; extensionASTNodes: ReadonlyArray<UnionTypeExtensionNode> }
Returns
TypeDescription
{ 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 value

toString()

Returns the schema coordinate identifying this union type.

Signature:

toString(): string
Returns
TypeDescription
stringThe 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
TypeDescription
stringThe JSON-serializable representation.
Example
const json = unionType.toJSON();
 
// json: the JSON representation

GraphQLEnumType

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
NameTypeDescription
configReadonly<GraphQLEnumTypeConfig>Configuration describing this object.
Returns
TypeDescription
GraphQLEnumType

Members

NameTypeDescription
namestringThe GraphQL name for this schema element.
descriptionnull | undefined | stringHuman-readable description for this schema element, if provided.
extensionsReadonly<GraphQLEnumTypeExtensions>Extension fields to include in the formatted result.
astNodenull | undefined | EnumTypeDefinitionNodeAST node from which this schema element was built, if available.
extensionASTNodesreadonly EnumTypeExtensionNode[]AST extension nodes applied to this schema element.

getValues()

Returns the values defined by this enum type.

Signature:

getValues(): readonly GraphQLEnumValue[]
Returns
TypeDescription
readonly GraphQLEnumValue[]The enum values.
Example
// Given a GraphQLEnumType instance named enumType:
const result = enumType.getValues();
 
// result contains the getValues return value

getValue()

Returns the enum value definition for a value name.

Signature:

getValue(name: string): null | undefined | GraphQLEnumValue
Arguments
NameTypeDescription
namestringThe GraphQL name to look up.
Returns
TypeDescription
null | undefined | GraphQLEnumValueThe matching enum value definition, if it exists.
Example
// Given a GraphQLEnumType instance named enumType:
const result = enumType.getValue(name);
 
// result contains the getValue return value

serialize()

Serializes a runtime enum value as a GraphQL enum name.

Signature:

serialize(outputValue: unknown): null | undefined | string
Arguments
NameTypeDescription
outputValueunknownRuntime enum value to serialize.
Returns
TypeDescription
null | undefined | stringThe GraphQL enum name for the runtime value.
Example
// Given a GraphQLEnumType instance named enumType:
const result = enumType.serialize(outputValue);
 
// result contains the serialize return value

parseValue()

Parses a GraphQL enum name from variable input.

Signature:

parseValue(inputValue: unknown): any
Arguments
NameTypeDescription
inputValueunknownRuntime input value to parse.
Returns
TypeDescription
anyThe 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 value

parseLiteral()

Parses a GraphQL enum name from an AST value literal.

Signature:

parseLiteral(valueNode: ValueNode, _variables: null | undefined | object): any
Arguments
NameTypeDescription
valueNodeValueNodeAST value literal to parse.
_variablesnull | undefined | objectRuntime variable values; ignored because enum literals cannot contain variables.
Returns
TypeDescription
anyThe 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 value

toConfig()

Returns a normalized configuration object for this object.

Signature:

toConfig(): { values: object; extensions: Readonly<GraphQLEnumTypeExtensions>; extensionASTNodes: ReadonlyArray<EnumTypeExtensionNode> }
Returns
TypeDescription
{ 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 value

toString()

Returns the schema coordinate identifying this enum type.

Signature:

toString(): string
Returns
TypeDescription
stringThe 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
TypeDescription
stringThe JSON-serializable representation.
Example
const json = enumType.toJSON();
 
// json: the JSON representation

GraphQLInputObjectType

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
NameTypeDescription
configReadonly<GraphQLInputObjectTypeConfig>Configuration describing this object.
Returns
TypeDescription
GraphQLInputObjectType

Members

NameTypeDescription
namestringThe GraphQL name for this schema element.
descriptionnull | undefined | stringHuman-readable description for this schema element, if provided.
extensionsReadonly<GraphQLInputObjectTypeExtensions>Extension fields to include in the formatted result.
astNodenull | undefined | InputObjectTypeDefinitionNodeAST node from which this schema element was built, if available.
extensionASTNodesreadonly InputObjectTypeExtensionNode[]AST extension nodes applied to this schema element.
isOneOfbooleanWhether this input object uses the experimental OneOf input object semantics.

getFields()

Returns the fields defined by this type.

Signature:

getFields(): GraphQLInputFieldMap
Returns
TypeDescription
GraphQLInputFieldMapThe fields keyed by field name.
Example
// Given a GraphQLInputObjectType instance named inputObjectType:
const result = inputObjectType.getFields();
 
// result contains the getFields return value

toConfig()

Returns a normalized configuration object for this object.

Signature:

toConfig(): { fields: GraphQLInputFieldConfigMap; extensions: Readonly<GraphQLInputObjectTypeExtensions>; extensionASTNodes: ReadonlyArray<InputObjectTypeExtensionNode> }
Returns
TypeDescription
{ 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 value

toString()

Returns the schema coordinate identifying this input object type.

Signature:

toString(): string
Returns
TypeDescription
stringThe 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
TypeDescription
stringThe JSON-serializable representation.
Example
const json = inputObjectType.toJSON();
 
// json: the JSON representation

Functions

isType()

Returns true when the value is any GraphQL type.

Signature:

isType(type: unknown): type is GraphQLType

Arguments

NameTypeDescription
typeunknownThe GraphQL type to inspect.

Returns

TypeDescription
type is GraphQLTypeTrue when the value matches this type.

Example

import { isType, GraphQLString } from 'graphql/type';
 
const result = isType(GraphQLString);
 
// result: true for matching GraphQL types

assertType()

Returns the value as a GraphQL type, or throws if it is not one.

Signature:

assertType(type: unknown): GraphQLType

Arguments

NameTypeDescription
typeunknownThe GraphQL type to inspect.

Returns

TypeDescription
GraphQLTypeThe value typed as a GraphQL type.

Example

import { assertType, GraphQLString } from 'graphql/type';
 
const type = assertType(GraphQLString);
 
// type: GraphQLString

isScalarType()

There are predicates for each kind of GraphQL type.

Signature:

isScalarType(type: unknown): type is GraphQLScalarType<unknown, unknown>

Arguments

NameTypeDescription
typeunknownThe GraphQL type to inspect.

Returns

TypeDescription
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 types

assertScalarType()

Returns the value as a GraphQLScalarType, or throws if it is not one.

Signature:

assertScalarType(type: unknown): GraphQLScalarType

Arguments

NameTypeDescription
typeunknownThe GraphQL type to inspect.

Returns

TypeDescription
GraphQLScalarTypeThe value typed as a GraphQLScalarType.

Example

import { assertScalarType, GraphQLString } from 'graphql/type';
 
const type = assertScalarType(GraphQLString);
 
// type: GraphQLString

isObjectType()

Returns true when the value is a GraphQLObjectType.

Signature:

isObjectType(type: unknown): type is GraphQLObjectType

Arguments

NameTypeDescription
typeunknownThe GraphQL type to inspect.

Returns

TypeDescription
type is GraphQLObjectTypeTrue when the value matches this type.

Example

import { isObjectType, GraphQLString } from 'graphql/type';
 
const result = isObjectType(GraphQLString);
 
// result: true for matching GraphQL types

assertObjectType()

Returns the value as a GraphQLObjectType, or throws if it is not one.

Signature:

assertObjectType(type: unknown): GraphQLObjectType

Arguments

NameTypeDescription
typeunknownThe GraphQL type to inspect.

Returns

TypeDescription
GraphQLObjectTypeThe value typed as a GraphQLObjectType.

Example

import { assertObjectType, GraphQLString } from 'graphql/type';
 
const type = assertObjectType(GraphQLString);
 
// type: GraphQLString

isInterfaceType()

Returns true when the value is a GraphQLInterfaceType.

Signature:

isInterfaceType(type: unknown): type is GraphQLInterfaceType

Arguments

NameTypeDescription
typeunknownThe GraphQL type to inspect.

Returns

TypeDescription
type is GraphQLInterfaceTypeTrue when the value matches this type.

Example

import { isInterfaceType, GraphQLString } from 'graphql/type';
 
const result = isInterfaceType(GraphQLString);
 
// result: true for matching GraphQL types

assertInterfaceType()

Returns the value as a GraphQLInterfaceType, or throws if it is not one.

Signature:

assertInterfaceType(type: unknown): GraphQLInterfaceType

Arguments

NameTypeDescription
typeunknownThe GraphQL type to inspect.

Returns

TypeDescription
GraphQLInterfaceTypeThe value typed as a GraphQLInterfaceType.

Example

import { assertInterfaceType, GraphQLString } from 'graphql/type';
 
const type = assertInterfaceType(GraphQLString);
 
// type: GraphQLString

isUnionType()

Returns true when the value is a GraphQLUnionType.

Signature:

isUnionType(type: unknown): type is GraphQLUnionType

Arguments

NameTypeDescription
typeunknownThe GraphQL type to inspect.

Returns

TypeDescription
type is GraphQLUnionTypeTrue when the value matches this type.

Example

import { isUnionType, GraphQLString } from 'graphql/type';
 
const result = isUnionType(GraphQLString);
 
// result: true for matching GraphQL types

assertUnionType()

Returns the value as a GraphQLUnionType, or throws if it is not one.

Signature:

assertUnionType(type: unknown): GraphQLUnionType

Arguments

NameTypeDescription
typeunknownThe GraphQL type to inspect.

Returns

TypeDescription
GraphQLUnionTypeThe value typed as a GraphQLUnionType.

Example

import { assertUnionType, GraphQLString } from 'graphql/type';
 
const type = assertUnionType(GraphQLString);
 
// type: GraphQLString

isEnumType()

Returns true when the value is a GraphQLEnumType.

Signature:

isEnumType(type: unknown): type is GraphQLEnumType

Arguments

NameTypeDescription
typeunknownThe GraphQL type to inspect.

Returns

TypeDescription
type is GraphQLEnumTypeTrue when the value matches this type.

Example

import { isEnumType, GraphQLString } from 'graphql/type';
 
const result = isEnumType(GraphQLString);
 
// result: true for matching GraphQL types

assertEnumType()

Returns the value as a GraphQLEnumType, or throws if it is not one.

Signature:

assertEnumType(type: unknown): GraphQLEnumType

Arguments

NameTypeDescription
typeunknownThe GraphQL type to inspect.

Returns

TypeDescription
GraphQLEnumTypeThe value typed as a GraphQLEnumType.

Example

import { assertEnumType, GraphQLString } from 'graphql/type';
 
const type = assertEnumType(GraphQLString);
 
// type: GraphQLString

isInputObjectType()

Returns true when the value is a GraphQLInputObjectType.

Signature:

isInputObjectType(type: unknown): type is GraphQLInputObjectType

Arguments

NameTypeDescription
typeunknownThe GraphQL type to inspect.

Returns

TypeDescription
type is GraphQLInputObjectTypeTrue when the value matches this type.

Example

import { isInputObjectType, GraphQLString } from 'graphql/type';
 
const result = isInputObjectType(GraphQLString);
 
// result: true for matching GraphQL types

assertInputObjectType()

Returns the value as a GraphQLInputObjectType, or throws if it is not one.

Signature:

assertInputObjectType(type: unknown): GraphQLInputObjectType

Arguments

NameTypeDescription
typeunknownThe GraphQL type to inspect.

Returns

TypeDescription
GraphQLInputObjectTypeThe value typed as a GraphQLInputObjectType.

Example

import { assertInputObjectType, GraphQLString } from 'graphql/type';
 
const type = assertInputObjectType(GraphQLString);
 
// type: GraphQLString

isListType()

Overload 1

Returns true when the value is a GraphQLList.

Signature:

isListType(type: GraphQLInputType): type is GraphQLList<GraphQLInputType>
Arguments
NameTypeDescription
typeGraphQLInputTypeThe GraphQL type to inspect.
Returns
TypeDescription
type is GraphQLList<GraphQLInputType>True when the value matches this type.
Example
import { GraphQLList, GraphQLString, isListType } from 'graphql/type';
 
isListType(new GraphQLList(GraphQLString));
 
// true

Overload 2

Returns true when the output type is a GraphQLList.

Signature:

isListType(type: GraphQLOutputType): type is GraphQLList<GraphQLOutputType>
Arguments
NameTypeDescription
typeGraphQLOutputTypeThe GraphQL output type to inspect.
Returns
TypeDescription
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
NameTypeDescription
typeunknownThe value to inspect.
Returns
TypeDescription
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

NameTypeDescription
typeunknownThe GraphQL type to inspect.

Returns

TypeDescription
GraphQLList<GraphQLType>The value typed as a GraphQLList.

Example

import { assertListType, GraphQLString } from 'graphql/type';
 
const type = assertListType(GraphQLString);
 
// type: GraphQLString

isNonNullType()

Overload 1

Returns true when the value is a GraphQLNonNull.

Signature:

isNonNullType(type: GraphQLInputType): type is GraphQLNonNull<GraphQLInputType>
Arguments
NameTypeDescription
typeGraphQLInputTypeThe GraphQL type to inspect.
Returns
TypeDescription
type is GraphQLNonNull<GraphQLInputType>True when the value matches this type.
Example
import { GraphQLNonNull, GraphQLString, isNonNullType } from 'graphql/type';
 
isNonNullType(new GraphQLNonNull(GraphQLString));
 
// true

Overload 2

Returns true when the output type is a GraphQLNonNull.

Signature:

isNonNullType(type: GraphQLOutputType): type is GraphQLNonNull<GraphQLOutputType>
Arguments
NameTypeDescription
typeGraphQLOutputTypeThe GraphQL output type to inspect.
Returns
TypeDescription
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
NameTypeDescription
typeunknownThe value to inspect.
Returns
TypeDescription
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

NameTypeDescription
typeunknownThe GraphQL type to inspect.

Returns

TypeDescription
GraphQLNonNull<GraphQLType>The value typed as a GraphQLNonNull.

Example

import { assertNonNullType, GraphQLString } from 'graphql/type';
 
const type = assertNonNullType(GraphQLString);
 
// type: GraphQLString

isInputType()

Returns true when the value can be used as a GraphQL input type.

Signature:

isInputType(type: unknown): type is GraphQLInputType

Arguments

NameTypeDescription
typeunknownThe GraphQL type to inspect.

Returns

TypeDescription
type is GraphQLInputTypeTrue when the value matches this type.

Example

import { isInputType, GraphQLString } from 'graphql/type';
 
const result = isInputType(GraphQLString);
 
// result: true for matching GraphQL types

assertInputType()

Returns the value as a GraphQL input type, or throws if it is not one.

Signature:

assertInputType(type: unknown): GraphQLInputType

Arguments

NameTypeDescription
typeunknownThe GraphQL type to inspect.

Returns

TypeDescription
GraphQLInputTypeThe value typed as a GraphQL input type.

Example

import { assertInputType, GraphQLString } from 'graphql/type';
 
const type = assertInputType(GraphQLString);
 
// type: GraphQLString

isOutputType()

Returns true when the value can be used as a GraphQL output type.

Signature:

isOutputType(type: unknown): type is GraphQLOutputType

Arguments

NameTypeDescription
typeunknownThe GraphQL type to inspect.

Returns

TypeDescription
type is GraphQLOutputTypeTrue when the value matches this type.

Example

import { isOutputType, GraphQLString } from 'graphql/type';
 
const result = isOutputType(GraphQLString);
 
// result: true for matching GraphQL types

assertOutputType()

Returns the value as a GraphQL output type, or throws if it is not one.

Signature:

assertOutputType(type: unknown): GraphQLOutputType

Arguments

NameTypeDescription
typeunknownThe GraphQL type to inspect.

Returns

TypeDescription
GraphQLOutputTypeThe value typed as a GraphQL output type.

Example

import { assertOutputType, GraphQLString } from 'graphql/type';
 
const type = assertOutputType(GraphQLString);
 
// type: GraphQLString

isLeafType()

Returns true when the value is a GraphQL scalar or enum type.

Signature:

isLeafType(type: unknown): type is GraphQLLeafType

Arguments

NameTypeDescription
typeunknownThe GraphQL type to inspect.

Returns

TypeDescription
type is GraphQLLeafTypeTrue when the value matches this type.

Example

import { isLeafType, GraphQLString } from 'graphql/type';
 
const result = isLeafType(GraphQLString);
 
// result: true for matching GraphQL types

assertLeafType()

Returns the value as a GraphQL leaf type, or throws if it is not one.

Signature:

assertLeafType(type: unknown): GraphQLLeafType

Arguments

NameTypeDescription
typeunknownThe GraphQL type to inspect.

Returns

TypeDescription
GraphQLLeafTypeThe value typed as a GraphQL leaf type.

Example

import { assertLeafType, GraphQLString } from 'graphql/type';
 
const type = assertLeafType(GraphQLString);
 
// type: GraphQLString

isCompositeType()

Returns true when the value is a GraphQL object, interface, or union type.

Signature:

isCompositeType(type: unknown): type is GraphQLCompositeType

Arguments

NameTypeDescription
typeunknownThe GraphQL type to inspect.

Returns

TypeDescription
type is GraphQLCompositeTypeTrue when the value matches this type.

Example

import { isCompositeType, GraphQLString } from 'graphql/type';
 
const result = isCompositeType(GraphQLString);
 
// result: true for matching GraphQL types

assertCompositeType()

Returns the value as a GraphQL composite type, or throws if it is not one.

Signature:

assertCompositeType(type: unknown): GraphQLCompositeType

Arguments

NameTypeDescription
typeunknownThe GraphQL type to inspect.

Returns

TypeDescription
GraphQLCompositeTypeThe value typed as a GraphQL composite type.

Example

import { assertCompositeType, GraphQLString } from 'graphql/type';
 
const type = assertCompositeType(GraphQLString);
 
// type: GraphQLString

isAbstractType()

Returns true when the value is a GraphQL interface or union type.

Signature:

isAbstractType(type: unknown): type is GraphQLAbstractType

Arguments

NameTypeDescription
typeunknownThe GraphQL type to inspect.

Returns

TypeDescription
type is GraphQLAbstractTypeTrue when the value matches this type.

Example

import { isAbstractType, GraphQLString } from 'graphql/type';
 
const result = isAbstractType(GraphQLString);
 
// result: true for matching GraphQL types

assertAbstractType()

Returns the value as a GraphQL abstract type, or throws if it is not one.

Signature:

assertAbstractType(type: unknown): GraphQLAbstractType

Arguments

NameTypeDescription
typeunknownThe GraphQL type to inspect.

Returns

TypeDescription
GraphQLAbstractTypeThe value typed as a GraphQL abstract type.

Example

import { assertAbstractType, GraphQLString } from 'graphql/type';
 
const type = assertAbstractType(GraphQLString);
 
// type: GraphQLString

isWrappingType()

Returns true when the value is a GraphQL list or non-null wrapper type.

Signature:

isWrappingType(type: unknown): type is GraphQLWrappingType

Arguments

NameTypeDescription
typeunknownThe GraphQL type to inspect.

Returns

TypeDescription
type is GraphQLWrappingTypeTrue when the value matches this type.

Example

import { isWrappingType, GraphQLString } from 'graphql/type';
 
const result = isWrappingType(GraphQLString);
 
// result: true for matching GraphQL types

assertWrappingType()

Returns the value as a GraphQL wrapping type, or throws if it is not one.

Signature:

assertWrappingType(type: unknown): GraphQLWrappingType

Arguments

NameTypeDescription
typeunknownThe GraphQL type to inspect.

Returns

TypeDescription
GraphQLWrappingTypeThe value typed as a GraphQL wrapping type.

Example

import { assertWrappingType, GraphQLString } from 'graphql/type';
 
const type = assertWrappingType(GraphQLString);
 
// type: GraphQLString

isNullableType()

Returns true when the value is a GraphQL type that can accept null.

Signature:

isNullableType(type: unknown): type is GraphQLNullableType

Arguments

NameTypeDescription
typeunknownThe GraphQL type to inspect.

Returns

TypeDescription
type is GraphQLNullableTypeTrue when the value matches this type.

Example

import { isNullableType, GraphQLString } from 'graphql/type';
 
const result = isNullableType(GraphQLString);
 
// result: true for matching GraphQL types

assertNullableType()

Returns the value as a nullable GraphQL type, or throws if it is not one.

Signature:

assertNullableType(type: unknown): GraphQLNullableType

Arguments

NameTypeDescription
typeunknownThe GraphQL type to inspect.

Returns

TypeDescription
GraphQLNullableTypeThe value typed as a nullable GraphQL type.

Example

import { assertNullableType, GraphQLString } from 'graphql/type';
 
const type = assertNullableType(GraphQLString);
 
// type: GraphQLString

getNullableType()

Overload 1

Returns the nullable type.

Signature:

getNullableType(type: null | undefined): void
Arguments
NameTypeDescription
typenull | undefinedThe GraphQL type to inspect.
Example
import { getNullableType } from 'graphql/type';
 
getNullableType(null);
 
// undefined

Overload 2

Returns the nullable type after removing one non-null wrapper.

Type Parameters
NameConstraintDefaultDescription
TGraphQLNullableTypeThe nullable GraphQL type returned after removing one non-null wrapper.

Signature:

getNullableType<T extends GraphQLNullableType>(type: T | GraphQLNonNull<T>): T
Arguments
NameTypeDescription
typeT | GraphQLNonNull<T>A nullable type or non-null wrapper.
Returns
TypeDescription
TThe 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
NameTypeDescription
typenull | undefined | GraphQLTypeThe GraphQL type to inspect.
Returns
TypeDescription
GraphQLNullableType | undefinedThe 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

NameTypeDescription
typeunknownThe GraphQL type to inspect.

Returns

TypeDescription
type is GraphQLNamedTypeTrue when the value matches this type.

Example

import { isNamedType, GraphQLString } from 'graphql/type';
 
const result = isNamedType(GraphQLString);
 
// result: true for matching GraphQL types

assertNamedType()

Returns the value as a GraphQL named type, or throws if it is not one.

Signature:

assertNamedType(type: unknown): GraphQLNamedType

Arguments

NameTypeDescription
typeunknownThe GraphQL type to inspect.

Returns

TypeDescription
GraphQLNamedTypeThe value typed as a GraphQL named type.

Example

import { assertNamedType, GraphQLString } from 'graphql/type';
 
const type = assertNamedType(GraphQLString);
 
// type: GraphQLString

getNamedType()

Overload 1

Returns the named type.

Signature:

getNamedType(type: null | undefined): void
Arguments
NameTypeDescription
typenull | undefinedThe GraphQL type to inspect.
Example
import { getNamedType } from 'graphql/type';
 
getNamedType(null);
 
// undefined

Overload 2

Returns the named input type after unwrapping all list and non-null wrappers.

Signature:

getNamedType(type: GraphQLInputType): GraphQLNamedInputType
Arguments
NameTypeDescription
typeGraphQLInputTypeThe GraphQL input type to inspect.
Returns
TypeDescription
GraphQLNamedInputTypeThe 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
NameTypeDescription
typeGraphQLOutputTypeThe GraphQL output type to inspect.
Returns
TypeDescription
GraphQLNamedOutputTypeThe 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
NameTypeDescription
typeGraphQLTypeThe GraphQL type to inspect.
Returns
TypeDescription
GraphQLNamedTypeThe 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
NameTypeDescription
typenull | undefined | GraphQLTypeThe GraphQL type to inspect.
Returns
TypeDescription
GraphQLNamedType | undefinedThe named type after unwrapping all wrappers, or undefined for nullish input.

resolveReadonlyArrayThunk()

Resolves a thunked readonly array.

Type Parameters

NameConstraintDefaultDescription
TThe element type resolved from the thunk or array.

Signature:

resolveReadonlyArrayThunk<T>(thunk: ThunkReadonlyArray<T>): readonly T[]

Arguments

NameTypeDescription
thunkThunkReadonlyArray<T>The thunk or value to resolve.

Returns

TypeDescription
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

NameConstraintDefaultDescription
TThe object-map value type resolved from the thunk or map.

Signature:

resolveObjMapThunk<T>(thunk: ThunkObjMap<T>): object

Arguments

NameTypeDescription
thunkThunkObjMap<T>The thunk or value to resolve.

Returns

TypeDescription
objectThe resolved object map.

Example

import { GraphQLString, resolveObjMapThunk } from 'graphql/type';
 
const fields = resolveObjMapThunk(() => ({ name: GraphQLString }));
 
// fields.name: GraphQLString

isRequiredArgument()

Returns true when the argument is non-null and has no default value.

Signature:

isRequiredArgument(arg: GraphQLArgument): boolean

Arguments

NameTypeDescription
argGraphQLArgumentThe argument definition to inspect.

Returns

TypeDescription
booleanTrue when the value matches this type.

Example

import { isRequiredArgument, GraphQLString } from 'graphql/type';
 
const result = isRequiredArgument(GraphQLString);
 
// result: true for matching GraphQL types

isRequiredInputField()

Returns true when the input field is non-null and has no default value.

Signature:

isRequiredInputField(field: GraphQLInputField): boolean

Arguments

NameTypeDescription
fieldGraphQLInputFieldThe input field definition to inspect.

Returns

TypeDescription
booleanTrue when the value matches this type.

Example

import { isRequiredInputField, GraphQLString } from 'graphql/type';
 
const result = isRequiredInputField(GraphQLString);
 
// result: true for matching GraphQL types

Types

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

NameConstraintDefaultDescription
TThe 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

NameConstraintDefaultDescription
TThe 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

NameConstraintDefaultDescription
TExternalThe 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

NameConstraintDefaultDescription
TInternalThe 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

NameConstraintDefaultDescription
TInternalThe 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

NameConstraintDefaultDescription
TInternalThe internal runtime representation accepted by this scalar.
TExternalThe serialized representation exposed in GraphQL results.

Members

NameTypeDescription
namestringThe GraphQL name for this schema element.
description?null | undefined | stringHuman-readable description for this schema element, if provided.
specifiedByURL?null | undefined | stringURL 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 | ScalarTypeDefinitionNodeAST 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

NameConstraintDefaultDescription
_TSourceanyThe JavaScript source value type associated with this object type.
_TContextanyThe application context type passed to resolvers for this object type.

GraphQLObjectTypeConfig

Interface. Configuration used to construct a GraphQLObjectType.

Type Parameters

NameConstraintDefaultDescription
TSourceThe JavaScript source value type resolved as this object type.
TContextThe application context type passed to this object type’s resolvers.

Members

NameTypeDescription
namestringThe GraphQL name for this schema element.
description?null | undefined | stringHuman-readable description for this schema element, if provided.
interfaces?ThunkReadonlyArray<GraphQLInterfaceType>Interfaces implemented by this object or interface type.
fieldsThunkObjMap<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 | ObjectTypeDefinitionNodeAST 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

NameConstraintDefaultDescription
TSourceThe JavaScript source value being resolved to a concrete object type.
TContextThe 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

NameConstraintDefaultDescription
TSourceThe JavaScript source value tested against this object type.
TContextThe 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

NameConstraintDefaultDescription
TSourceThe JavaScript source value passed to the field resolver.
TContextThe application context type passed to the field resolver.
TArgsanyThe field argument map type passed to the field resolver.
TResultunknownThe 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

NameTypeDescription
fieldNamestringThe field name referenced by this schema coordinate.
fieldNodesreadonly FieldNode[]AST field nodes that contributed to the current field execution.
returnTypeGraphQLOutputTypeGraphQL output type declared for the current field.
parentTypeGraphQLObjectTypeObject type that owns the current field.
pathPathResponse path where this error occurred during execution.
schemaGraphQLSchemaThe schema used for validation or execution.
fragmentsobjectFragment definitions in the operation document keyed by fragment name.
rootValueunknownInitial root value passed to the operation.
operationOperationDefinitionNodeThe operation selected for execution.
variableValuesobjectRuntime 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

NameConstraintDefaultDescription
_TSourceThe JavaScript source value type associated with this field.
_TContextThe application context type associated with this field.
_TArgsanyThe field argument map type associated with this field.

GraphQLFieldConfig

Interface. Configuration used to define a GraphQL field.

Type Parameters

NameConstraintDefaultDescription
TSourceThe JavaScript source value type passed to this field’s resolver.
TContextThe application context type passed to this field’s resolver.
TArgsanyThe field argument map type passed to this field’s resolver.

Members

NameTypeDescription
description?null | undefined | stringHuman-readable description for this schema element, if provided.
typeGraphQLOutputTypeThe GraphQL type reference or runtime type for this element.
args?GraphQLFieldConfigArgumentMapArguments 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 | stringReason 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 | FieldDefinitionNodeAST 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

NameTypeDescription
description?null | undefined | stringHuman-readable description for this schema element, if provided.
typeGraphQLInputTypeThe GraphQL type reference or runtime type for this element.
defaultValue?unknownThe default value used when no explicit value is supplied.
deprecationReason?null | undefined | stringReason this element is deprecated, if one was provided.
extensions?null | undefined | Readonly<GraphQLArgumentExtensions>Extension fields to include in the formatted result.
astNode?null | undefined | InputValueDefinitionNodeAST node from which this schema element was built, if available.

GraphQLFieldConfigMap

Type alias. A map of field names to field configuration objects.

Type Parameters

NameConstraintDefaultDescription
TSourceThe JavaScript source value type for fields in this map.
TContextThe application context type for fields in this map.
type GraphQLFieldConfigMap<TSource, TContext> = object;

GraphQLField

Interface. A resolved GraphQL field definition.

Type Parameters

NameConstraintDefaultDescription
TSourceThe JavaScript source value type passed to this field’s resolver.
TContextThe application context type passed to this field’s resolver.
TArgsanyThe field argument map type passed to this field’s resolver.

Members

NameTypeDescription
namestringThe GraphQL name for this schema element.
descriptionnull | undefined | stringHuman-readable description for this schema element, if provided.
typeGraphQLOutputTypeThe GraphQL type reference or runtime type for this element.
argsreadonly 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.
deprecationReasonnull | undefined | stringReason this element is deprecated, if one was provided.
extensionsReadonly<GraphQLFieldExtensions<TSource, TContext, TArgs>>Extension fields to include in the formatted result.
astNodenull | undefined | FieldDefinitionNodeAST node from which this schema element was built, if available.

GraphQLArgument

Interface. A resolved GraphQL argument definition.

Members

NameTypeDescription
namestringThe GraphQL name for this schema element.
descriptionnull | undefined | stringHuman-readable description for this schema element, if provided.
typeGraphQLInputTypeThe GraphQL type reference or runtime type for this element.
defaultValueunknownThe default value used when no explicit value is supplied.
deprecationReasonnull | undefined | stringReason this element is deprecated, if one was provided.
extensionsReadonly<GraphQLArgumentExtensions>Extension fields to include in the formatted result.
astNodenull | undefined | InputValueDefinitionNodeAST node from which this schema element was built, if available.

GraphQLFieldMap

Type alias. A map of field names to resolved field definitions.

Type Parameters

NameConstraintDefaultDescription
TSourceThe JavaScript source value type for resolved fields in this map.
TContextThe 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

NameConstraintDefaultDescription
TSourceThe JavaScript source value type resolved as an implementing object type.
TContextThe application context type passed to this interface type’s resolvers.

Members

NameTypeDescription
namestringThe GraphQL name for this schema element.
description?null | undefined | stringHuman-readable description for this schema element, if provided.
interfaces?ThunkReadonlyArray<GraphQLInterfaceType>Interfaces implemented by this object or interface type.
fieldsThunkObjMap<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 implementing
Object type.
extensions?null | undefined | Readonly<GraphQLInterfaceTypeExtensions>Extension fields to include in the formatted result.
astNode?null | undefined | InterfaceTypeDefinitionNodeAST 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

NameConstraintDefaultDescription
TSourceThe JavaScript source value type resolved as a union member.
TContextThe application context type passed to this union type’s resolver.

Members

NameTypeDescription
namestringThe GraphQL name for this schema element.
description?null | undefined | stringHuman-readable description for this schema element, if provided.
typesThunkReadonlyArray<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 implementing
Object type.
extensions?null | undefined | Readonly<GraphQLUnionTypeExtensions>Extension fields to include in the formatted result.
astNode?null | undefined | UnionTypeDefinitionNodeAST 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

NameTypeDescription
namestringThe GraphQL name for this schema element.
description?null | undefined | stringHuman-readable description for this schema element, if provided.
valuesThunkObjMap<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 | EnumTypeDefinitionNodeAST 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

NameTypeDescription
description?null | undefined | stringHuman-readable description for this schema element, if provided.
value?anyThe parsed value represented by this node.
deprecationReason?null | undefined | stringReason this element is deprecated, if one was provided.
extensions?null | undefined | Readonly<GraphQLEnumValueExtensions>Extension fields to include in the formatted result.
astNode?null | undefined | EnumValueDefinitionNodeAST node from which this schema element was built, if available.

GraphQLEnumValue

Interface. A resolved GraphQL enum value definition.

Members

NameTypeDescription
namestringThe GraphQL name for this schema element.
descriptionnull | undefined | stringHuman-readable description for this schema element, if provided.
valueanyThe parsed value represented by this node.
deprecationReasonnull | undefined | stringReason this element is deprecated, if one was provided.
extensionsReadonly<GraphQLEnumValueExtensions>Extension fields to include in the formatted result.
astNodenull | undefined | EnumValueDefinitionNodeAST 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

NameTypeDescription
namestringThe GraphQL name for this schema element.
description?null | undefined | stringHuman-readable description for this schema element, if provided.
fieldsThunkObjMap<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 | InputObjectTypeDefinitionNodeAST node from which this schema element was built, if available.
extensionASTNodes?null | undefined | readonly InputObjectTypeExtensionNode[]AST extension nodes applied to this schema element.
isOneOf?booleanWhether 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

NameTypeDescription
description?null | undefined | stringHuman-readable description for this schema element, if provided.
typeGraphQLInputTypeThe GraphQL type reference or runtime type for this element.
defaultValue?unknownThe default value used when no explicit value is supplied.
deprecationReason?null | undefined | stringReason this element is deprecated, if one was provided.
extensions?null | undefined | Readonly<GraphQLInputFieldExtensions>Extension fields to include in the formatted result.
astNode?null | undefined | InputValueDefinitionNodeAST 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

NameTypeDescription
namestringThe GraphQL name for this schema element.
descriptionnull | undefined | stringHuman-readable description for this schema element, if provided.
typeGraphQLInputTypeThe GraphQL type reference or runtime type for this element.
defaultValueunknownThe default value used when no explicit value is supplied.
deprecationReasonnull | undefined | stringReason this element is deprecated, if one was provided.
extensionsReadonly<GraphQLInputFieldExtensions>Extension fields to include in the formatted result.
astNodenull | undefined | InputValueDefinitionNodeAST 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;