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

BREAK

BREAK: unknown = ...

Parse and operate on GraphQL language source files.

DEFAULT_DEPRECATION_REASON

DEFAULT_DEPRECATION_REASON: No longer supported = 'No longer supported'

Create and operate on GraphQL type definitions and schema.

GraphQLBoolean

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

Create and operate on GraphQL type definitions and schema.

GraphQLDeprecatedDirective

GraphQLDeprecatedDirective: GraphQLDirective = ...

Create and operate on GraphQL type definitions and schema.

GraphQLFloat

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

Create and operate on GraphQL type definitions and schema.

GraphQLID

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

Create and operate on GraphQL type definitions and schema.

GraphQLIncludeDirective

GraphQLIncludeDirective: GraphQLDirective = ...

Create and operate on GraphQL type definitions and schema.

GraphQLInt

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

Create and operate on GraphQL type definitions and schema.

GraphQLSkipDirective

GraphQLSkipDirective: GraphQLDirective = ...

Create and operate on GraphQL type definitions and schema.

GraphQLSpecifiedByDirective

GraphQLSpecifiedByDirective: GraphQLDirective = ...

Create and operate on GraphQL type definitions and schema.

GraphQLString

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

Create and operate on GraphQL type definitions and schema.

SchemaMetaFieldDef

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

Create and operate on GraphQL type definitions and schema.

TypeMetaFieldDef

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

Create and operate on GraphQL type definitions and schema.

TypeNameMetaFieldDef

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

Create and operate on GraphQL type definitions and schema.

__Directive

__Directive: GraphQLObjectType = ...

Create and operate on GraphQL type definitions and schema.

__DirectiveLocation

__DirectiveLocation: GraphQLEnumType = ...

Create and operate on GraphQL type definitions and schema.

__EnumValue

__EnumValue: GraphQLObjectType = ...

Create and operate on GraphQL type definitions and schema.

__Field

__Field: GraphQLObjectType = ...

Create and operate on GraphQL type definitions and schema.

__InputValue

__InputValue: GraphQLObjectType = ...

Create and operate on GraphQL type definitions and schema.

__Schema

__Schema: GraphQLObjectType = ...

Create and operate on GraphQL type definitions and schema.

__Type

__Type: GraphQLObjectType = ...

Create and operate on GraphQL type definitions and schema.

__TypeKind

__TypeKind: GraphQLEnumType = ...

Create and operate on GraphQL type definitions and schema.

introspectionTypes

introspectionTypes: ReadonlyArray<GraphQLNamedType> = ...

Create and operate on GraphQL type definitions and schema.

specifiedDirectives

specifiedDirectives: ReadonlyArray<GraphQLDirective> = ...

Create and operate on GraphQL type definitions and schema.

specifiedRules

specifiedRules: ReadonlyArray<ValidationRule> = ...

Validate GraphQL documents.

specifiedScalarTypes

specifiedScalarTypes: ReadonlyArray<GraphQLScalarType> = ...

Create and operate on GraphQL type definitions and schema.

version

version: string = ...

The GraphQL.js version info.

versionInfo

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

The GraphQL.js version info.