Skip to main content

graphql

GraphQL.js provides a reference implementation for the GraphQL specification but is also a useful utility for operating on GraphQL files and building sophisticated tools.

This primary module exports a general purpose function for fulfilling all steps of the GraphQL specification in a single operation, but also includes utilities for every part of the GraphQL specification:

  • Parsing the GraphQL language.
  • Building a GraphQL type schema.
  • Validating a GraphQL request against a type schema.
  • Executing a GraphQL request against a type schema.

This also includes utility functions for operating on GraphQL types and GraphQL documents to facilitate building tools.

You may also import from each sub-directory directly. For example, the following two import statements are equivalent:

import { parse } from 'graphql';
import { parse } from 'graphql/language';

Index

Classes

Enumerations

Functions

Interfaces

Type aliases

Variables

Type aliases

ASTKindToNode

ASTKindToNode: { [ NodeT in ASTNode as NodeT[kind] ]: NodeT }

Utility type listing all nodes indexed by their kind.

ASTNode

The list of all possible AST node types.

ASTVisitFn

ASTVisitFn<TVisitedNode>: (node: TVisitedNode, key: string | number | undefined, parent: ASTNode | ReadonlyArray<ASTNode> | undefined, path: ReadonlyArray<string | number>, ancestors: ReadonlyArray<ASTNode | ReadonlyArray<ASTNode>>) => any

Type parameters

Type declaration

    • (node: TVisitedNode, key: string | number | undefined, parent: ASTNode | ReadonlyArray<ASTNode> | undefined, path: ReadonlyArray<string | number>, ancestors: ReadonlyArray<ASTNode | ReadonlyArray<ASTNode>>): any
    • A visitor is comprised of visit functions, which are called on each node during the visitor’s traversal.


      Parameters

      • node: TVisitedNode
      • key: string | number | undefined
      • parent: ASTNode | ReadonlyArray<ASTNode> | undefined
      • path: ReadonlyArray<string | number>
      • ancestors: ReadonlyArray<ASTNode | ReadonlyArray<ASTNode>>

      Returns any

ASTVisitor

ASTVisitor: EnterLeaveVisitor<ASTNode> | KindVisitor

A visitor is provided to visit, it contains the collection of relevant functions to be called during the visitor’s traversal.

ASTVisitorKeyMap

ASTVisitorKeyMap: { [ NodeT in ASTNode as NodeT[kind] ]?: ReadonlyArray<keyof NodeT> }

A KeyMap describes each the traversable properties of each kind of node.

@deprecated

Please inline it. Will be removed in v17

ConstValueNode

DefinitionNode

DirectiveLocationEnum

DirectiveLocationEnum: typeof DirectiveLocation

The enum type representing the directive location values.

@deprecated

Please use DirectiveLocation. Will be remove in v17.

ExecutableDefinitionNode

GraphQLAbstractType

GraphQLAbstractType: GraphQLInterfaceType | GraphQLUnionType

These types may describe the parent context of a selection set.

GraphQLCompositeType

These types may describe the parent context of a selection set.

GraphQLEnumValueConfigMap

GraphQLEnumValueConfigMap: ObjMap<GraphQLEnumValueConfig>

GraphQLFieldConfigArgumentMap

GraphQLFieldConfigArgumentMap: ObjMap<GraphQLArgumentConfig>

GraphQLFieldConfigMap

GraphQLFieldConfigMap<TSource, TContext>: ObjMap<GraphQLFieldConfig<TSource, TContext>>

Type parameters

  • TSource
  • TContext

GraphQLFieldMap

GraphQLFieldMap<TSource, TContext>: ObjMap<GraphQLField<TSource, TContext>>

Type parameters

  • TSource
  • TContext

GraphQLFieldResolver

GraphQLFieldResolver<TSource, TContext, TArgs, TResult>: (source: TSource, args: TArgs, context: TContext, info: GraphQLResolveInfo) => TResult

Type parameters

  • TSource
  • TContext
  • TArgs = any
  • TResult = unknown

Type declaration

GraphQLInputFieldConfigMap

GraphQLInputFieldConfigMap: ObjMap<GraphQLInputFieldConfig>

GraphQLInputFieldMap

GraphQLInputFieldMap: ObjMap<GraphQLInputField>

GraphQLInputType

These types may be used as input types for arguments and directives.

GraphQLIsTypeOfFn

GraphQLIsTypeOfFn<TSource, TContext>: (source: TSource, context: TContext, info: GraphQLResolveInfo) => PromiseOrValue<boolean>

Type parameters

  • TSource
  • TContext

Type declaration

    • Parameters

      Returns PromiseOrValue<boolean>

GraphQLLeafType

These types may describe types which may be leaf values.

GraphQLNamedInputType

GraphQLNamedOutputType

GraphQLNamedType

These named types do not include modifiers like List or NonNull.

GraphQLNullableType

These types can all accept null as a value.

GraphQLOutputType

These types may be used as output types as the result of fields.

GraphQLScalarLiteralParser

GraphQLScalarLiteralParser<TInternal>: (valueNode: ValueNode, variables?: Maybe<ObjMap<unknown>>) => TInternal

Type parameters

  • TInternal

Type declaration

    • (valueNode: ValueNode, variables?: Maybe<ObjMap<unknown>>): TInternal
    • Parameters

      • valueNode: ValueNode
      • optionalvariables: Maybe<ObjMap<unknown>>

      Returns TInternal

GraphQLScalarSerializer

GraphQLScalarSerializer<TExternal>: (outputValue: unknown) => TExternal

Type parameters

  • TExternal

Type declaration

    • (outputValue: unknown): TExternal
    • Parameters

      • outputValue: unknown

      Returns TExternal

GraphQLScalarValueParser

GraphQLScalarValueParser<TInternal>: (inputValue: unknown) => TInternal

Type parameters

  • TInternal

Type declaration

    • (inputValue: unknown): TInternal
    • Parameters

      • inputValue: unknown

      Returns TInternal

GraphQLType

These are all of the possible kinds of types.

GraphQLTypeResolver

GraphQLTypeResolver<TSource, TContext>: (value: TSource, context: TContext, info: GraphQLResolveInfo, abstractType: GraphQLAbstractType) => PromiseOrValue<string | undefined>

Type parameters

  • TSource
  • TContext

Type declaration

GraphQLWrappingType

These types wrap and modify other types

IntrospectionInputType

IntrospectionInputTypeRef

IntrospectionOutputType

IntrospectionOutputTypeRef

IntrospectionType

IntrospectionTypeRef

KindEnum

KindEnum: typeof Kind

The enum type representing the possible kind values of AST nodes.

@deprecated

Please use Kind. Will be remove in v17.

SelectionNode

ThunkObjMap

ThunkObjMap<T>: () => ObjMap<T> | ObjMap<T>

Type parameters

  • T

ThunkReadonlyArray

ThunkReadonlyArray<T>: () => ReadonlyArray<T> | ReadonlyArray<T>

Used while defining GraphQL types to allow for circular references in otherwise immutable type definitions.


Type parameters

  • T

TokenKindEnum

TokenKindEnum: typeof TokenKind

The enum type representing the token kinds values.

@deprecated

Please use TokenKind. Will be remove in v17.

TypeDefinitionNode

Type Definition

TypeExtensionNode

Type Extensions

TypeNode

Type Reference

TypeSystemDefinitionNode

Type System Definition

TypeSystemExtensionNode

TypeSystemExtensionNode: SchemaExtensionNode | TypeExtensionNode

Type System Extensions

ValidationRule

ValidationRule: (context: ValidationContext) => ASTVisitor

Type declaration

ValueNode

Values

Variables

constBREAK

BREAK: unknown = ...

constDEFAULT_DEPRECATION_REASON

DEFAULT_DEPRECATION_REASON: No longer supported = 'No longer supported'

Constant string used for default reason for a deprecation.

constGRAPHQL_MAX_INT

GRAPHQL_MAX_INT: 2147483647 = 2147483647

Maximum possible Int value as per GraphQL Spec (32-bit signed integer). n.b. This differs from JavaScript’s numbers that are IEEE 754 doubles safe up-to 2^53 - 1

constGRAPHQL_MIN_INT

GRAPHQL_MIN_INT: -2147483648 = -2147483648

Minimum possible Int value as per GraphQL Spec (32-bit signed integer). n.b. This differs from JavaScript’s numbers that are IEEE 754 doubles safe starting at -(2^53 - 1)

constGraphQLBoolean

GraphQLBoolean: GraphQLScalarType<boolean, boolean> = ...

constGraphQLDeprecatedDirective

GraphQLDeprecatedDirective: GraphQLDirective = ...

Used to declare element of a GraphQL schema as deprecated.

constGraphQLFloat

GraphQLFloat: GraphQLScalarType<number, number> = ...

constGraphQLID

GraphQLID: GraphQLScalarType<string, string> = ...

constGraphQLIncludeDirective

GraphQLIncludeDirective: GraphQLDirective = ...

Used to conditionally include fields or fragments.

constGraphQLInt

GraphQLInt: GraphQLScalarType<number, number> = ...

constGraphQLSkipDirective

GraphQLSkipDirective: GraphQLDirective = ...

Used to conditionally skip (exclude) fields or fragments.

constGraphQLSpecifiedByDirective

GraphQLSpecifiedByDirective: GraphQLDirective = ...

Used to provide a URL for specifying the behavior of custom scalar definitions.

constGraphQLString

GraphQLString: GraphQLScalarType<string, string> = ...

constSchemaMetaFieldDef

SchemaMetaFieldDef: GraphQLField<unknown, unknown> = ...

Note that these are GraphQLField and not GraphQLFieldConfig, so the format for args is different.

constTypeMetaFieldDef

TypeMetaFieldDef: GraphQLField<unknown, unknown> = ...

constTypeNameMetaFieldDef

TypeNameMetaFieldDef: GraphQLField<unknown, unknown> = ...

const__Directive

__Directive: GraphQLObjectType = ...

const__DirectiveLocation

__DirectiveLocation: GraphQLEnumType = ...

const__EnumValue

__EnumValue: GraphQLObjectType = ...

const__Field

__Field: GraphQLObjectType = ...

const__InputValue

__InputValue: GraphQLObjectType = ...

const__Schema

__Schema: GraphQLObjectType = ...

const__Type

__Type: GraphQLObjectType = ...

const__TypeKind

__TypeKind: GraphQLEnumType = ...

constintrospectionTypes

introspectionTypes: ReadonlyArray<GraphQLNamedType> = ...

constspecifiedDirectives

specifiedDirectives: ReadonlyArray<GraphQLDirective> = ...

The full list of specified directives.

constspecifiedRules

specifiedRules: ReadonlyArray<ValidationRule> = ...

This set includes all validation rules defined by the GraphQL spec.

The order of the rules in this list has been adjusted to lead to the most clear output when encountering multiple validation errors.

constspecifiedScalarTypes

specifiedScalarTypes: ReadonlyArray<GraphQLScalarType> = ...

constversion

version: string = ...

A string containing the version of the GraphQL.js library

constversionInfo

versionInfo: Readonly<{ major: number; minor: number; patch: number; preReleaseTag: null | string }> = ...

An object containing the components of the GraphQL.js version string