graphql
- Version 16.10.0
- Published
- 1.36 MB
- No dependencies
- MIT license
Install
npm i graphql
yarn add graphql
pnpm add graphql
Overview
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
Variables
- BREAK
- DEFAULT_DEPRECATION_REASON
- defaultFieldResolver
- defaultTypeResolver
- GRAPHQL_MAX_INT
- GRAPHQL_MIN_INT
- GraphQLBoolean
- GraphQLDeprecatedDirective
- GraphQLFloat
- GraphQLID
- GraphQLIncludeDirective
- GraphQLInt
- GraphQLOneOfDirective
- GraphQLSkipDirective
- GraphQLSpecifiedByDirective
- GraphQLString
- introspectionTypes
- recommendedRules
- SchemaMetaFieldDef
- specifiedDirectives
- specifiedRules
- specifiedScalarTypes
- TypeMetaFieldDef
- TypeNameMetaFieldDef
- version
- versionInfo
Functions
- assertAbstractType()
- assertCompositeType()
- assertDirective()
- assertEnumType()
- assertInputObjectType()
- assertInputType()
- assertInterfaceType()
- assertLeafType()
- assertListType()
- assertName()
- assertNamedType()
- assertNonNullType()
- assertNullableType()
- assertObjectType()
- assertOutputType()
- assertScalarType()
- assertSchema()
- assertType()
- assertUnionType()
- assertValidName()
- assertValidSchema()
- assertWrappingType()
- astFromValue()
- buildASTSchema()
- buildClientSchema()
- buildSchema()
- coerceInputValue()
- concatAST()
- createSourceEventStream()
- doTypesOverlap()
- ExecutableDefinitionsRule()
- execute()
- executeSync()
- extendSchema()
- FieldsOnCorrectTypeRule()
- findBreakingChanges()
- findDangerousChanges()
- formatError()
- FragmentsOnCompositeTypesRule()
- getArgumentValues()
- getDirectiveValues()
- getEnterLeaveForKind()
- getIntrospectionQuery()
- getLocation()
- getNamedType()
- getNullableType()
- getOperationAST()
- getOperationRootType()
- getVariableValues()
- getVisitFn()
- graphql()
- graphqlSync()
- introspectionFromSchema()
- isAbstractType()
- isCompositeType()
- isConstValueNode()
- isDefinitionNode()
- isDirective()
- isEnumType()
- isEqualType()
- isExecutableDefinitionNode()
- isInputObjectType()
- isInputType()
- isInterfaceType()
- isIntrospectionType()
- isLeafType()
- isListType()
- isNamedType()
- isNonNullType()
- isNullableType()
- isObjectType()
- isOutputType()
- isRequiredArgument()
- isRequiredInputField()
- isScalarType()
- isSchema()
- isSelectionNode()
- isSpecifiedDirective()
- isSpecifiedScalarType()
- isType()
- isTypeDefinitionNode()
- isTypeExtensionNode()
- isTypeNode()
- isTypeSubTypeOf()
- isTypeSystemDefinitionNode()
- isTypeSystemExtensionNode()
- isUnionType()
- isValidNameError()
- isValueNode()
- isWrappingType()
- KnownArgumentNamesRule()
- KnownDirectivesRule()
- KnownFragmentNamesRule()
- KnownTypeNamesRule()
- lexicographicSortSchema()
- locatedError()
- LoneAnonymousOperationRule()
- LoneSchemaDefinitionRule()
- MaxIntrospectionDepthRule()
- NoDeprecatedCustomRule()
- NoFragmentCyclesRule()
- NoSchemaIntrospectionCustomRule()
- NoUndefinedVariablesRule()
- NoUnusedFragmentsRule()
- NoUnusedVariablesRule()
- OverlappingFieldsCanBeMergedRule()
- parse()
- parseConstValue()
- parseType()
- parseValue()
- PossibleFragmentSpreadsRule()
- PossibleTypeExtensionsRule()
- print()
- printError()
- printIntrospectionSchema()
- printLocation()
- printSchema()
- printSourceLocation()
- printType()
- ProvidedRequiredArgumentsRule()
- resolveObjMapThunk()
- resolveReadonlyArrayThunk()
- responsePathAsArray()
- ScalarLeafsRule()
- separateOperations()
- SingleFieldSubscriptionsRule()
- stripIgnoredCharacters()
- subscribe()
- syntaxError()
- typeFromAST()
- UniqueArgumentDefinitionNamesRule()
- UniqueArgumentNamesRule()
- UniqueDirectiveNamesRule()
- UniqueDirectivesPerLocationRule()
- UniqueEnumValueNamesRule()
- UniqueFieldDefinitionNamesRule()
- UniqueFragmentNamesRule()
- UniqueInputFieldNamesRule()
- UniqueOperationNamesRule()
- UniqueOperationTypesRule()
- UniqueTypeNamesRule()
- UniqueVariableNamesRule()
- validate()
- validateSchema()
- valueFromAST()
- valueFromASTUntyped()
- ValuesOfCorrectTypeRule()
- VariablesAreInputTypesRule()
- VariablesInAllowedPositionRule()
- visit()
- visitInParallel()
- visitWithTypeInfo()
Classes
Interfaces
Enums
BreakingChangeType
- ARG_CHANGED_KIND
- ARG_REMOVED
- DIRECTIVE_ARG_REMOVED
- DIRECTIVE_LOCATION_REMOVED
- DIRECTIVE_REMOVED
- DIRECTIVE_REPEATABLE_REMOVED
- FIELD_CHANGED_KIND
- FIELD_REMOVED
- IMPLEMENTED_INTERFACE_REMOVED
- REQUIRED_ARG_ADDED
- REQUIRED_DIRECTIVE_ARG_ADDED
- REQUIRED_INPUT_FIELD_ADDED
- TYPE_CHANGED_KIND
- TYPE_REMOVED
- TYPE_REMOVED_FROM_UNION
- VALUE_REMOVED_FROM_ENUM
Kind
- ARGUMENT
- BOOLEAN
- DIRECTIVE
- DIRECTIVE_DEFINITION
- DOCUMENT
- ENUM
- ENUM_TYPE_DEFINITION
- ENUM_TYPE_EXTENSION
- ENUM_VALUE_DEFINITION
- FIELD
- FIELD_DEFINITION
- FLOAT
- FRAGMENT_DEFINITION
- FRAGMENT_SPREAD
- INLINE_FRAGMENT
- INPUT_OBJECT_TYPE_DEFINITION
- INPUT_OBJECT_TYPE_EXTENSION
- INPUT_VALUE_DEFINITION
- INT
- INTERFACE_TYPE_DEFINITION
- INTERFACE_TYPE_EXTENSION
- LIST
- LIST_TYPE
- NAME
- NAMED_TYPE
- NON_NULL_TYPE
- NULL
- OBJECT
- OBJECT_FIELD
- OBJECT_TYPE_DEFINITION
- OBJECT_TYPE_EXTENSION
- OPERATION_DEFINITION
- OPERATION_TYPE_DEFINITION
- SCALAR_TYPE_DEFINITION
- SCALAR_TYPE_EXTENSION
- SCHEMA_DEFINITION
- SCHEMA_EXTENSION
- SELECTION_SET
- STRING
- UNION_TYPE_DEFINITION
- UNION_TYPE_EXTENSION
- VARIABLE
- VARIABLE_DEFINITION
Type Aliases
- ASTKindToNode
- ASTNode
- ASTVisitFn
- ASTVisitor
- ASTVisitorKeyMap
- ConstValueNode
- DefinitionNode
- DirectiveLocationEnum
- ExecutableDefinitionNode
- GraphQLAbstractType
- GraphQLCompositeType
- GraphQLEnumValueConfigMap
- GraphQLFieldConfigArgumentMap
- GraphQLFieldConfigMap
- GraphQLFieldMap
- GraphQLFieldResolver
- GraphQLInputFieldConfigMap
- GraphQLInputFieldMap
- GraphQLInputType
- GraphQLIsTypeOfFn
- GraphQLLeafType
- GraphQLNamedInputType
- GraphQLNamedOutputType
- GraphQLNamedType
- GraphQLNullableType
- GraphQLOutputType
- GraphQLScalarLiteralParser
- GraphQLScalarSerializer
- GraphQLScalarValueParser
- GraphQLType
- GraphQLTypeResolver
- GraphQLWrappingType
- IntrospectionInputType
- IntrospectionInputTypeRef
- IntrospectionOutputType
- IntrospectionOutputTypeRef
- IntrospectionType
- IntrospectionTypeRef
- KindEnum
- SelectionNode
- ThunkObjMap
- ThunkReadonlyArray
- TokenKindEnum
- TypeDefinitionNode
- TypeExtensionNode
- TypeNode
- TypeSystemDefinitionNode
- TypeSystemExtensionNode
- ValidationRule
- ValueNode
Variables
variable BREAK
const BREAK: {};
variable DEFAULT_DEPRECATION_REASON
const DEFAULT_DEPRECATION_REASON: string;
Constant string used for default reason for a deprecation.
variable defaultFieldResolver
const defaultFieldResolver: GraphQLFieldResolver<unknown, unknown, any, unknown>;
If a resolve function is not given, then a default resolve behavior is used which takes the property of the source object of the same name as the field and returns it as the result, or if it's a function, returns the result of calling that function while passing along args and context value.
variable defaultTypeResolver
const defaultTypeResolver: GraphQLTypeResolver<unknown, unknown>;
If a resolveType function is not given, then a default resolve behavior is used which attempts two strategies:
First, See if the provided value has a
__typename
field defined, if so, use that value as name of the resolved type.Otherwise, test each possible type for the abstract type by calling isTypeOf for the object being coerced, returning the first type that matches.
variable GRAPHQL_MAX_INT
const GRAPHQL_MAX_INT: number;
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
variable GRAPHQL_MIN_INT
const GRAPHQL_MIN_INT: number;
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)
variable GraphQLBoolean
const GraphQLBoolean: GraphQLScalarType<boolean, boolean>;
variable GraphQLDeprecatedDirective
const GraphQLDeprecatedDirective: GraphQLDirective;
Used to declare element of a GraphQL schema as deprecated.
variable GraphQLFloat
const GraphQLFloat: GraphQLScalarType<number, number>;
variable GraphQLID
const GraphQLID: GraphQLScalarType<string, string>;
variable GraphQLIncludeDirective
const GraphQLIncludeDirective: GraphQLDirective;
Used to conditionally include fields or fragments.
variable GraphQLInt
const GraphQLInt: GraphQLScalarType<number, number>;
variable GraphQLOneOfDirective
const GraphQLOneOfDirective: GraphQLDirective;
Used to indicate an Input Object is a OneOf Input Object.
variable GraphQLSkipDirective
const GraphQLSkipDirective: GraphQLDirective;
Used to conditionally skip (exclude) fields or fragments.
variable GraphQLSpecifiedByDirective
const GraphQLSpecifiedByDirective: GraphQLDirective;
Used to provide a URL for specifying the behavior of custom scalar definitions.
variable GraphQLString
const GraphQLString: GraphQLScalarType<string, string>;
variable introspectionTypes
const introspectionTypes: readonly GraphQLNamedType[];
variable recommendedRules
const recommendedRules: readonly ((context: ASTValidationContext) => ASTVisitor)[];
Technically these aren't part of the spec but they are strongly encouraged validation rules.
variable SchemaMetaFieldDef
const SchemaMetaFieldDef: GraphQLField<unknown, unknown, any>;
Note that these are GraphQLField and not GraphQLFieldConfig, so the format for args is different.
variable specifiedDirectives
const specifiedDirectives: readonly GraphQLDirective[];
The full list of specified directives.
variable specifiedRules
const specifiedRules: readonly 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.
variable specifiedScalarTypes
const specifiedScalarTypes: readonly GraphQLScalarType<unknown, unknown>[];
variable TypeMetaFieldDef
const TypeMetaFieldDef: GraphQLField<unknown, unknown, any>;
variable TypeNameMetaFieldDef
const TypeNameMetaFieldDef: GraphQLField<unknown, unknown, any>;
variable version
const version: string;
A string containing the version of the GraphQL.js library
variable versionInfo
const versionInfo: Readonly<{ major: number; minor: number; patch: number; preReleaseTag: string | null;}>;
An object containing the components of the GraphQL.js version string
Functions
function assertAbstractType
assertAbstractType: (type: unknown) => GraphQLAbstractType;
function assertCompositeType
assertCompositeType: (type: unknown) => GraphQLCompositeType;
function assertDirective
assertDirective: (directive: unknown) => GraphQLDirective;
function assertEnumType
assertEnumType: (type: unknown) => GraphQLEnumType;
function assertInputObjectType
assertInputObjectType: (type: unknown) => GraphQLInputObjectType;
function assertInputType
assertInputType: (type: unknown) => GraphQLInputType;
function assertInterfaceType
assertInterfaceType: (type: unknown) => GraphQLInterfaceType;
function assertLeafType
assertLeafType: (type: unknown) => GraphQLLeafType;
function assertListType
assertListType: (type: unknown) => GraphQLList<GraphQLType>;
function assertName
assertName: (name: string) => string;
Upholds the spec rules about naming.
function assertNamedType
assertNamedType: (type: unknown) => GraphQLNamedType;
function assertNonNullType
assertNonNullType: (type: unknown) => GraphQLNonNull<GraphQLType>;
function assertNullableType
assertNullableType: (type: unknown) => GraphQLNullableType;
function assertObjectType
assertObjectType: (type: unknown) => GraphQLObjectType;
function assertOutputType
assertOutputType: (type: unknown) => GraphQLOutputType;
function assertScalarType
assertScalarType: (type: unknown) => GraphQLScalarType;
function assertSchema
assertSchema: (schema: unknown) => GraphQLSchema;
function assertType
assertType: (type: unknown) => GraphQLType;
function assertUnionType
assertUnionType: (type: unknown) => GraphQLUnionType;
function assertValidName
assertValidName: (name: string) => string;
Upholds the spec rules about naming.
Deprecated
Please use
assertName
instead. Will be removed in v17
function assertValidSchema
assertValidSchema: (schema: GraphQLSchema) => void;
Utility function which asserts a schema is valid by throwing an error if it is invalid.
function assertWrappingType
assertWrappingType: (type: unknown) => GraphQLWrappingType;
function astFromValue
astFromValue: (value: unknown, type: GraphQLInputType) => Maybe<ValueNode>;
Produces a GraphQL Value AST given a JavaScript object. Function will match JavaScript/JSON values to GraphQL AST schema format by using suggested GraphQLInputType. For example:
astFromValue("value", GraphQLString)
A GraphQL type must be provided, which will be used to interpret different JavaScript values.
| JSON Value | GraphQL Value | | ------------- | -------------------- | | Object | Input Object | | Array | List | | Boolean | Boolean | | String | String / Enum Value | | Number | Int / Float | | Unknown | Enum Value | | null | NullValue |
function buildASTSchema
buildASTSchema: ( documentAST: DocumentNode, options?: BuildSchemaOptions) => GraphQLSchema;
This takes the ast of a schema document produced by the parse function in src/language/parser.js.
If no schema definition is provided, then it will look for types named Query, Mutation and Subscription.
Given that AST it constructs a GraphQLSchema. The resulting schema has no resolve methods, so execution will use default resolvers.
function buildClientSchema
buildClientSchema: ( introspection: IntrospectionQuery, options?: GraphQLSchemaValidationOptions) => GraphQLSchema;
Build a GraphQLSchema for use by client tools.
Given the result of a client running the introspection query, creates and returns a GraphQLSchema instance which can be then used with all graphql-js tools, but cannot be used to execute a query, as introspection does not represent the "resolver", "parse" or "serialize" functions or any other server-internal mechanisms.
This function expects a complete introspection result. Don't forget to check the "errors" field of a server response before calling this function.
function buildSchema
buildSchema: ( source: string | Source, options?: BuildSchemaOptions & ParseOptions) => GraphQLSchema;
A helper function to build a GraphQLSchema directly from a source document.
function coerceInputValue
coerceInputValue: ( inputValue: unknown, type: GraphQLInputType, onError?: OnErrorCB) => unknown;
Coerces a JavaScript value given a GraphQL Input Type.
function concatAST
concatAST: (documents: ReadonlyArray<DocumentNode>) => DocumentNode;
Provided a collection of ASTs, presumably each from different files, concatenate the ASTs together into batched AST, useful for validating many GraphQL source files which together represent one conceptual application.
function createSourceEventStream
createSourceEventStream: { (args: ExecutionArgs): Promise<AsyncIterable<unknown> | ExecutionResult>; ( schema: GraphQLSchema, document: DocumentNode, rootValue?: unknown, contextValue?: unknown, variableValues?: { readonly [variable: string]: unknown }, operationName?: string, subscribeFieldResolver?: GraphQLFieldResolver<any, any, any, unknown> ): Promise< ExecutionResult<ObjMap<unknown>, ObjMap<unknown>> | AsyncIterable<unknown> >;};
Implements the "CreateSourceEventStream" algorithm described in the GraphQL specification, resolving the subscription source event stream.
Returns a Promise which resolves to either an AsyncIterable (if successful) or an ExecutionResult (error). The promise will be rejected if the schema or other arguments to this function are invalid, or if the resolved event stream is not an async iterable.
If the client-provided arguments to this function do not result in a compliant subscription, a GraphQL Response (ExecutionResult) with descriptive errors and no data will be returned.
If the the source stream could not be created due to faulty subscription resolver logic or underlying systems, the promise will resolve to a single ExecutionResult containing
errors
and nodata
.If the operation succeeded, the promise resolves to the AsyncIterable for the event stream returned by the resolver.
A Source Event Stream represents a sequence of events, each of which triggers a GraphQL execution for that event.
This may be useful when hosting the stateful subscription service in a different process or machine than the stateless GraphQL execution engine, or otherwise separating these two steps. For more on this, see the "Supporting Subscriptions at Scale" information in the GraphQL specification.
Deprecated
will be removed in next major version in favor of named arguments
function doTypesOverlap
doTypesOverlap: ( schema: GraphQLSchema, typeA: GraphQLCompositeType, typeB: GraphQLCompositeType) => boolean;
Provided two composite types, determine if they "overlap". Two composite types overlap when the Sets of possible concrete types for each intersect.
This is often used to determine if a fragment of a given type could possibly be visited in a context of another type.
This function is commutative.
function ExecutableDefinitionsRule
ExecutableDefinitionsRule: (context: ASTValidationContext) => ASTVisitor;
Executable definitions
A GraphQL document is only valid for execution if all definitions are either operation or fragment definitions.
See https://spec.graphql.org/draft/#sec-Executable-Definitions
function execute
execute: (args: ExecutionArgs) => PromiseOrValue<ExecutionResult>;
Implements the "Executing requests" section of the GraphQL specification.
Returns either a synchronous ExecutionResult (if all encountered resolvers are synchronous), or a Promise of an ExecutionResult that will eventually be resolved and never rejected.
If the arguments to this function do not result in a legal execution context, a GraphQLError will be thrown immediately explaining the invalid input.
function executeSync
executeSync: (args: ExecutionArgs) => ExecutionResult;
Also implements the "Executing requests" section of the GraphQL specification. However, it guarantees to complete synchronously (or throw an error) assuming that all field resolvers are also synchronous.
function extendSchema
extendSchema: ( schema: GraphQLSchema, documentAST: DocumentNode, options?: Options) => GraphQLSchema;
Produces a new schema given an existing schema and a document which may contain GraphQL type extensions and definitions. The original schema will remain unaltered.
Because a schema represents a graph of references, a schema cannot be extended without effectively making an entire copy. We do not know until it's too late if subgraphs remain unchanged.
This algorithm copies the provided schema, applying extensions while producing the copy. The original schema remains unaltered.
function FieldsOnCorrectTypeRule
FieldsOnCorrectTypeRule: (context: ValidationContext) => ASTVisitor;
Fields on correct type
A GraphQL document is only valid if all fields selected are defined by the parent type, or are an allowed meta field such as __typename.
See https://spec.graphql.org/draft/#sec-Field-Selections
function findBreakingChanges
findBreakingChanges: ( oldSchema: GraphQLSchema, newSchema: GraphQLSchema) => Array<BreakingChange>;
Given two schemas, returns an Array containing descriptions of all the types of breaking changes covered by the other functions down below.
function findDangerousChanges
findDangerousChanges: ( oldSchema: GraphQLSchema, newSchema: GraphQLSchema) => Array<DangerousChange>;
Given two schemas, returns an Array containing descriptions of all the types of potentially dangerous changes covered by the other functions down below.
function formatError
formatError: (error: GraphQLError) => GraphQLFormattedError;
Given a GraphQLError, format it according to the rules described by the Response Format, Errors section of the GraphQL Specification.
Deprecated
Please use
error.toJSON
instead. Will be removed in v17
function FragmentsOnCompositeTypesRule
FragmentsOnCompositeTypesRule: (context: ValidationContext) => ASTVisitor;
Fragments on composite type
Fragments use a type condition to determine if they apply, since fragments can only be spread into a composite type (object, interface, or union), the type condition must also be a composite type.
See https://spec.graphql.org/draft/#sec-Fragments-On-Composite-Types
function getArgumentValues
getArgumentValues: ( def: GraphQLField<unknown, unknown> | GraphQLDirective, node: FieldNode | DirectiveNode, variableValues?: Maybe<ObjMap<unknown>>) => { [argument: string]: unknown };
Prepares an object map of argument values given a list of argument definitions and list of argument AST nodes.
Note: The returned value is a plain Object with a prototype, since it is exposed to user code. Care should be taken to not pull values from the Object prototype.
function getDirectiveValues
getDirectiveValues: ( directiveDef: GraphQLDirective, node: { readonly directives?: ReadonlyArray<DirectiveNode> }, variableValues?: Maybe<ObjMap<unknown>>) => { [argument: string]: unknown };
Prepares an object map of argument values given a directive definition and a AST node which may contain directives. Optionally also accepts a map of variable values.
If the directive does not exist on the node, returns undefined.
Note: The returned value is a plain Object with a prototype, since it is exposed to user code. Care should be taken to not pull values from the Object prototype.
function getEnterLeaveForKind
getEnterLeaveForKind: ( visitor: ASTVisitor, kind: Kind) => EnterLeaveVisitor<ASTNode>;
Given a visitor instance and a node kind, return EnterLeaveVisitor for that kind.
function getIntrospectionQuery
getIntrospectionQuery: (options?: IntrospectionOptions) => string;
Produce the GraphQL query recommended for a full schema introspection. Accepts optional IntrospectionOptions.
function getLocation
getLocation: (source: Source, position: number) => SourceLocation;
Takes a Source and a UTF-8 character offset, and returns the corresponding line and column as a SourceLocation.
function getNamedType
getNamedType: { (type: undefined | null): void; (type: GraphQLInputType): GraphQLNamedInputType; (type: GraphQLOutputType): GraphQLNamedOutputType; (type: GraphQLType): GraphQLNamedType; (type: GraphQLType): GraphQLNamedType;};
function getNullableType
getNullableType: { (type: undefined | null): void; <T extends GraphQLNullableType>(type: T | GraphQLNonNull<T>): T; (type: GraphQLType): GraphQLNullableType;};
function getOperationAST
getOperationAST: ( documentAST: DocumentNode, operationName?: Maybe<string>) => Maybe<OperationDefinitionNode>;
Returns an operation AST given a document AST and optionally an operation name. If a name is not provided, an operation is only returned if only one is provided in the document.
function getOperationRootType
getOperationRootType: ( schema: GraphQLSchema, operation: OperationDefinitionNode | OperationTypeDefinitionNode) => GraphQLObjectType;
Extracts the root type of the operation from the schema.
Deprecated
Please use
GraphQLSchema.getRootType
instead. Will be removed in v17
function getVariableValues
getVariableValues: ( schema: GraphQLSchema, varDefNodes: ReadonlyArray<VariableDefinitionNode>, inputs: { readonly [variable: string]: unknown }, options?: { maxErrors?: number }) => CoercedVariableValues;
Prepares an object map of variableValues of the correct type based on the provided variable definitions and arbitrary input. If the input cannot be parsed to match the variable definitions, a GraphQLError will be thrown.
Note: The returned value is a plain Object with a prototype, since it is exposed to user code. Care should be taken to not pull values from the Object prototype.
function getVisitFn
getVisitFn: ( visitor: ASTVisitor, kind: Kind, isLeaving: boolean) => ASTVisitFn<ASTNode> | undefined;
Given a visitor instance, if it is leaving or not, and a node kind, return the function the visitor runtime should call.
Deprecated
Please use
getEnterLeaveForKind
instead. Will be removed in v17
function graphql
graphql: (args: GraphQLArgs) => Promise<ExecutionResult>;
function graphqlSync
graphqlSync: (args: GraphQLArgs) => ExecutionResult;
The graphqlSync function also fulfills GraphQL operations by parsing, validating, and executing a GraphQL document along side a GraphQL schema. However, it guarantees to complete synchronously (or throw an error) assuming that all field resolvers are also synchronous.
function introspectionFromSchema
introspectionFromSchema: ( schema: GraphQLSchema, options?: IntrospectionOptions) => IntrospectionQuery;
Build an IntrospectionQuery from a GraphQLSchema
IntrospectionQuery is useful for utilities that care about type and field relationships, but do not need to traverse through those relationships.
This is the inverse of buildClientSchema. The primary use case is outside of the server context, for instance when doing schema comparisons.
function isAbstractType
isAbstractType: (type: unknown) => type is GraphQLAbstractType;
function isCompositeType
isCompositeType: (type: unknown) => type is GraphQLCompositeType;
function isConstValueNode
isConstValueNode: (node: ASTNode) => node is ConstValueNode;
function isDefinitionNode
isDefinitionNode: (node: ASTNode) => node is DefinitionNode;
function isDirective
isDirective: (directive: unknown) => directive is GraphQLDirective;
Test if the given value is a GraphQL directive.
function isEnumType
isEnumType: (type: unknown) => type is GraphQLEnumType;
function isEqualType
isEqualType: (typeA: GraphQLType, typeB: GraphQLType) => boolean;
Provided two types, return true if the types are equal (invariant).
function isExecutableDefinitionNode
isExecutableDefinitionNode: (node: ASTNode) => node is ExecutableDefinitionNode;
function isInputObjectType
isInputObjectType: (type: unknown) => type is GraphQLInputObjectType;
function isInputType
isInputType: (type: unknown) => type is GraphQLInputType;
function isInterfaceType
isInterfaceType: (type: unknown) => type is GraphQLInterfaceType;
function isIntrospectionType
isIntrospectionType: (type: GraphQLNamedType) => boolean;
function isLeafType
isLeafType: (type: unknown) => type is GraphQLLeafType;
function isListType
isListType: { (type: GraphQLInputType): type is GraphQLList<GraphQLInputType>; (type: GraphQLOutputType): type is GraphQLList<GraphQLOutputType>; (type: unknown): type is GraphQLList<GraphQLType>;};
function isNamedType
isNamedType: (type: unknown) => type is GraphQLNamedType;
function isNonNullType
isNonNullType: { (type: GraphQLInputType): type is GraphQLNonNull<GraphQLInputType>; (type: GraphQLOutputType): type is GraphQLNonNull<GraphQLOutputType>; (type: unknown): type is GraphQLNonNull<GraphQLType>;};
function isNullableType
isNullableType: (type: unknown) => type is GraphQLNullableType;
function isObjectType
isObjectType: (type: unknown) => type is GraphQLObjectType<any, any>;
function isOutputType
isOutputType: (type: unknown) => type is GraphQLOutputType;
function isRequiredArgument
isRequiredArgument: (arg: GraphQLArgument) => boolean;
function isRequiredInputField
isRequiredInputField: (field: GraphQLInputField) => boolean;
function isScalarType
isScalarType: (type: unknown) => type is GraphQLScalarType<unknown, unknown>;
There are predicates for each kind of GraphQL type.
function isSchema
isSchema: (schema: unknown) => schema is GraphQLSchema;
Test if the given value is a GraphQL schema.
function isSelectionNode
isSelectionNode: (node: ASTNode) => node is SelectionNode;
function isSpecifiedDirective
isSpecifiedDirective: (directive: GraphQLDirective) => boolean;
function isSpecifiedScalarType
isSpecifiedScalarType: (type: GraphQLNamedType) => boolean;
function isType
isType: (type: unknown) => type is GraphQLType;
function isTypeDefinitionNode
isTypeDefinitionNode: (node: ASTNode) => node is TypeDefinitionNode;
function isTypeExtensionNode
isTypeExtensionNode: (node: ASTNode) => node is TypeExtensionNode;
function isTypeNode
isTypeNode: (node: ASTNode) => node is TypeNode;
function isTypeSubTypeOf
isTypeSubTypeOf: ( schema: GraphQLSchema, maybeSubType: GraphQLType, superType: GraphQLType) => boolean;
Provided a type and a super type, return true if the first type is either equal or a subset of the second super type (covariant).
function isTypeSystemDefinitionNode
isTypeSystemDefinitionNode: (node: ASTNode) => node is TypeSystemDefinitionNode;
function isTypeSystemExtensionNode
isTypeSystemExtensionNode: (node: ASTNode) => node is TypeSystemExtensionNode;
function isUnionType
isUnionType: (type: unknown) => type is GraphQLUnionType;
function isValidNameError
isValidNameError: (name: string) => GraphQLError | undefined;
Returns an Error if a name is invalid.
Deprecated
Please use
assertName
instead. Will be removed in v17
function isValueNode
isValueNode: (node: ASTNode) => node is ValueNode;
function isWrappingType
isWrappingType: (type: unknown) => type is GraphQLWrappingType;
function KnownArgumentNamesRule
KnownArgumentNamesRule: (context: ValidationContext) => ASTVisitor;
Known argument names
A GraphQL field is only valid if all supplied arguments are defined by that field.
See https://spec.graphql.org/draft/#sec-Argument-Names See https://spec.graphql.org/draft/#sec-Directives-Are-In-Valid-Locations
function KnownDirectivesRule
KnownDirectivesRule: ( context: ValidationContext | SDLValidationContext) => ASTVisitor;
Known directives
A GraphQL document is only valid if all
@directives
are known by the schema and legally positioned.See https://spec.graphql.org/draft/#sec-Directives-Are-Defined
function KnownFragmentNamesRule
KnownFragmentNamesRule: (context: ValidationContext) => ASTVisitor;
Known fragment names
A GraphQL document is only valid if all
...Fragment
fragment spreads refer to fragments defined in the same document.See https://spec.graphql.org/draft/#sec-Fragment-spread-target-defined
function KnownTypeNamesRule
KnownTypeNamesRule: ( context: ValidationContext | SDLValidationContext) => ASTVisitor;
Known type names
A GraphQL document is only valid if referenced types (specifically variable definitions and fragment conditions) are defined by the type schema.
See https://spec.graphql.org/draft/#sec-Fragment-Spread-Type-Existence
function lexicographicSortSchema
lexicographicSortSchema: (schema: GraphQLSchema) => GraphQLSchema;
Sort GraphQLSchema.
This function returns a sorted copy of the given GraphQLSchema.
function locatedError
locatedError: ( rawOriginalError: unknown, nodes: ASTNode | ReadonlyArray<ASTNode> | undefined | null, path?: Maybe<ReadonlyArray<string | number>>) => GraphQLError;
Given an arbitrary value, presumably thrown while attempting to execute a GraphQL operation, produce a new GraphQLError aware of the location in the document responsible for the original Error.
function LoneAnonymousOperationRule
LoneAnonymousOperationRule: (context: ASTValidationContext) => ASTVisitor;
Lone anonymous operation
A GraphQL document is only valid if when it contains an anonymous operation (the query short-hand) that it contains only that one operation definition.
See https://spec.graphql.org/draft/#sec-Lone-Anonymous-Operation
function LoneSchemaDefinitionRule
LoneSchemaDefinitionRule: (context: SDLValidationContext) => ASTVisitor;
Lone Schema definition
A GraphQL document is only valid if it contains only one schema definition.
function MaxIntrospectionDepthRule
MaxIntrospectionDepthRule: (context: ASTValidationContext) => ASTVisitor;
function NoDeprecatedCustomRule
NoDeprecatedCustomRule: (context: ValidationContext) => ASTVisitor;
No deprecated
A GraphQL document is only valid if all selected fields and all used enum values have not been deprecated.
Note: This rule is optional and is not part of the Validation section of the GraphQL Specification. The main purpose of this rule is detection of deprecated usages and not necessarily to forbid their use when querying a service.
function NoFragmentCyclesRule
NoFragmentCyclesRule: (context: ASTValidationContext) => ASTVisitor;
No fragment cycles
The graph of fragment spreads must not form any cycles including spreading itself. Otherwise an operation could infinitely spread or infinitely execute on cycles in the underlying data.
See https://spec.graphql.org/draft/#sec-Fragment-spreads-must-not-form-cycles
function NoSchemaIntrospectionCustomRule
NoSchemaIntrospectionCustomRule: (context: ValidationContext) => ASTVisitor;
Prohibit introspection queries
A GraphQL document is only valid if all fields selected are not fields that return an introspection type.
Note: This rule is optional and is not part of the Validation section of the GraphQL Specification. This rule effectively disables introspection, which does not reflect best practices and should only be done if absolutely necessary.
function NoUndefinedVariablesRule
NoUndefinedVariablesRule: (context: ValidationContext) => ASTVisitor;
No undefined variables
A GraphQL operation is only valid if all variables encountered, both directly and via fragment spreads, are defined by that operation.
See https://spec.graphql.org/draft/#sec-All-Variable-Uses-Defined
function NoUnusedFragmentsRule
NoUnusedFragmentsRule: (context: ASTValidationContext) => ASTVisitor;
No unused fragments
A GraphQL document is only valid if all fragment definitions are spread within operations, or spread within other fragments spread within operations.
See https://spec.graphql.org/draft/#sec-Fragments-Must-Be-Used
function NoUnusedVariablesRule
NoUnusedVariablesRule: (context: ValidationContext) => ASTVisitor;
No unused variables
A GraphQL operation is only valid if all variables defined by an operation are used, either directly or within a spread fragment.
See https://spec.graphql.org/draft/#sec-All-Variables-Used
function OverlappingFieldsCanBeMergedRule
OverlappingFieldsCanBeMergedRule: (context: ValidationContext) => ASTVisitor;
Overlapping fields can be merged
A selection set is only valid if all fields (including spreading any fragments) either correspond to distinct response names or can be merged without ambiguity.
See https://spec.graphql.org/draft/#sec-Field-Selection-Merging
function parse
parse: ( source: string | Source, options?: ParseOptions | undefined) => DocumentNode;
Given a GraphQL source, parses it into a Document. Throws GraphQLError if a syntax error is encountered.
function parseConstValue
parseConstValue: ( source: string | Source, options?: ParseOptions | undefined) => ConstValueNode;
Similar to parseValue(), but raises a parse error if it encounters a variable. The return type will be a constant value.
function parseType
parseType: ( source: string | Source, options?: ParseOptions | undefined) => TypeNode;
Given a string containing a GraphQL Type (ex.
[Int!]
), parse the AST for that type. Throws GraphQLError if a syntax error is encountered.This is useful within tools that operate upon GraphQL Types directly and in isolation of complete GraphQL documents.
Consider providing the results to the utility function: typeFromAST().
function parseValue
parseValue: ( source: string | Source, options?: ParseOptions | undefined) => ValueNode;
Given a string containing a GraphQL value (ex.
[42]
), parse the AST for that value. Throws GraphQLError if a syntax error is encountered.This is useful within tools that operate upon GraphQL Values directly and in isolation of complete GraphQL documents.
Consider providing the results to the utility function: valueFromAST().
function PossibleFragmentSpreadsRule
PossibleFragmentSpreadsRule: (context: ValidationContext) => ASTVisitor;
Possible fragment spread
A fragment spread is only valid if the type condition could ever possibly be true: if there is a non-empty intersection of the possible parent types, and possible types which pass the type condition.
function PossibleTypeExtensionsRule
PossibleTypeExtensionsRule: (context: SDLValidationContext) => ASTVisitor;
Possible type extension
A type extension is only valid if the type is defined and has the same kind.
function print
print: (ast: ASTNode) => string;
Converts an AST into a string, using one set of reasonable formatting rules.
function printError
printError: (error: GraphQLError) => string;
Prints a GraphQLError to a string, representing useful location information about the error's position in the source.
Deprecated
Please use
error.toString
instead. Will be removed in v17
function printIntrospectionSchema
printIntrospectionSchema: (schema: GraphQLSchema) => string;
function printLocation
printLocation: (location: Location) => string;
Render a helpful description of the location in the GraphQL Source document.
function printSchema
printSchema: (schema: GraphQLSchema) => string;
function printSourceLocation
printSourceLocation: (source: Source, sourceLocation: SourceLocation) => string;
Render a helpful description of the location in the GraphQL Source document.
function printType
printType: (type: GraphQLNamedType) => string;
function ProvidedRequiredArgumentsRule
ProvidedRequiredArgumentsRule: (context: ValidationContext) => ASTVisitor;
Provided required arguments
A field or directive is only valid if all required (non-null without a default value) field arguments have been provided.
function resolveObjMapThunk
resolveObjMapThunk: <T>(thunk: ThunkObjMap<T>) => ObjMap<T>;
function resolveReadonlyArrayThunk
resolveReadonlyArrayThunk: <T>(thunk: ThunkReadonlyArray<T>) => ReadonlyArray<T>;
function responsePathAsArray
responsePathAsArray: (path: Maybe<Readonly<Path>>) => Array<string | number>;
Given a Path, return an Array of the path keys.
function ScalarLeafsRule
ScalarLeafsRule: (context: ValidationContext) => ASTVisitor;
Scalar leafs
A GraphQL document is valid only if all leaf fields (fields without sub selections) are of scalar or enum types.
function separateOperations
separateOperations: (documentAST: DocumentNode) => ObjMap<DocumentNode>;
separateOperations accepts a single AST document which may contain many operations and fragments and returns a collection of AST documents each of which contains a single operation as well the fragment definitions it refers to.
function SingleFieldSubscriptionsRule
SingleFieldSubscriptionsRule: (context: ValidationContext) => ASTVisitor;
Subscriptions must only include a non-introspection field.
A GraphQL subscription is valid only if it contains a single root field and that root field is not an introspection field.
See https://spec.graphql.org/draft/#sec-Single-root-field
function stripIgnoredCharacters
stripIgnoredCharacters: (source: string | Source) => string;
Strips characters that are not significant to the validity or execution of a GraphQL document: - UnicodeBOM - WhiteSpace - LineTerminator - Comment - Comma - BlockString indentation
Note: It is required to have a delimiter character between neighboring non-punctuator tokens and this function always uses single space as delimiter.
It is guaranteed that both input and output documents if parsed would result in the exact same AST except for nodes location.
Warning: It is guaranteed that this function will always produce stable results. However, it's not guaranteed that it will stay the same between different releases due to bugfixes or changes in the GraphQL specification.
Query example:
query SomeQuery($foo: String!, $bar: String) {someField(foo: $foo, bar: $bar) {ab {cd}}}Becomes:
query SomeQuery($foo:String!$bar:String){someField(foo:$foo bar:$bar){a b{c d}}}SDL example:
"""Type description"""type Foo {"""Field description"""bar: String}Becomes:
"""Type description""" type Foo{"""Field description""" bar:String}
function subscribe
subscribe: ( args: ExecutionArgs) => Promise<AsyncGenerator<ExecutionResult, void, void> | ExecutionResult>;
Implements the "Subscribe" algorithm described in the GraphQL specification.
Returns a Promise which resolves to either an AsyncIterator (if successful) or an ExecutionResult (error). The promise will be rejected if the schema or other arguments to this function are invalid, or if the resolved event stream is not an async iterable.
If the client-provided arguments to this function do not result in a compliant subscription, a GraphQL Response (ExecutionResult) with descriptive errors and no data will be returned.
If the source stream could not be created due to faulty subscription resolver logic or underlying systems, the promise will resolve to a single ExecutionResult containing
errors
and nodata
.If the operation succeeded, the promise resolves to an AsyncIterator, which yields a stream of ExecutionResults representing the response stream.
Accepts either an object with named arguments, or individual arguments.
function syntaxError
syntaxError: ( source: Source, position: number, description: string) => GraphQLError;
Produces a GraphQLError representing a syntax error, containing useful descriptive information about the syntax error's position in the source.
function typeFromAST
typeFromAST: { (schema: GraphQLSchema, typeNode: NamedTypeNode): GraphQLNamedType | undefined; (schema: GraphQLSchema, typeNode: ListTypeNode): GraphQLList<any>; (schema: GraphQLSchema, typeNode: NonNullTypeNode): GraphQLNonNull<any>; (schema: GraphQLSchema, typeNode: TypeNode): GraphQLType;};
Given a Schema and an AST node describing a type, return a GraphQLType definition which applies to that type. For example, if provided the parsed AST node for
[User]
, a GraphQLList instance will be returned, containing the type called "User" found in the schema. If a type called "User" is not found in the schema, then undefined will be returned.
function UniqueArgumentDefinitionNamesRule
UniqueArgumentDefinitionNamesRule: (context: SDLValidationContext) => ASTVisitor;
Unique argument definition names
A GraphQL Object or Interface type is only valid if all its fields have uniquely named arguments. A GraphQL Directive is only valid if all its arguments are uniquely named.
function UniqueArgumentNamesRule
UniqueArgumentNamesRule: (context: ASTValidationContext) => ASTVisitor;
Unique argument names
A GraphQL field or directive is only valid if all supplied arguments are uniquely named.
See https://spec.graphql.org/draft/#sec-Argument-Names
function UniqueDirectiveNamesRule
UniqueDirectiveNamesRule: (context: SDLValidationContext) => ASTVisitor;
Unique directive names
A GraphQL document is only valid if all defined directives have unique names.
function UniqueDirectivesPerLocationRule
UniqueDirectivesPerLocationRule: ( context: ValidationContext | SDLValidationContext) => ASTVisitor;
Unique directive names per location
A GraphQL document is only valid if all non-repeatable directives at a given location are uniquely named.
See https://spec.graphql.org/draft/#sec-Directives-Are-Unique-Per-Location
function UniqueEnumValueNamesRule
UniqueEnumValueNamesRule: (context: SDLValidationContext) => ASTVisitor;
Unique enum value names
A GraphQL enum type is only valid if all its values are uniquely named.
function UniqueFieldDefinitionNamesRule
UniqueFieldDefinitionNamesRule: (context: SDLValidationContext) => ASTVisitor;
Unique field definition names
A GraphQL complex type is only valid if all its fields are uniquely named.
function UniqueFragmentNamesRule
UniqueFragmentNamesRule: (context: ASTValidationContext) => ASTVisitor;
Unique fragment names
A GraphQL document is only valid if all defined fragments have unique names.
See https://spec.graphql.org/draft/#sec-Fragment-Name-Uniqueness
function UniqueInputFieldNamesRule
UniqueInputFieldNamesRule: (context: ASTValidationContext) => ASTVisitor;
Unique input field names
A GraphQL input object value is only valid if all supplied fields are uniquely named.
See https://spec.graphql.org/draft/#sec-Input-Object-Field-Uniqueness
function UniqueOperationNamesRule
UniqueOperationNamesRule: (context: ASTValidationContext) => ASTVisitor;
Unique operation names
A GraphQL document is only valid if all defined operations have unique names.
See https://spec.graphql.org/draft/#sec-Operation-Name-Uniqueness
function UniqueOperationTypesRule
UniqueOperationTypesRule: (context: SDLValidationContext) => ASTVisitor;
Unique operation types
A GraphQL document is only valid if it has only one type per operation.
function UniqueTypeNamesRule
UniqueTypeNamesRule: (context: SDLValidationContext) => ASTVisitor;
Unique type names
A GraphQL document is only valid if all defined types have unique names.
function UniqueVariableNamesRule
UniqueVariableNamesRule: (context: ASTValidationContext) => ASTVisitor;
Unique variable names
A GraphQL operation is only valid if all its variables are uniquely named.
function validate
validate: ( schema: GraphQLSchema, documentAST: DocumentNode, rules?: ReadonlyArray<ValidationRule>, options?: { maxErrors?: number }, typeInfo?: TypeInfo) => ReadonlyArray<GraphQLError>;
Implements the "Validation" section of the spec.
Validation runs synchronously, returning an array of encountered errors, or an empty array if no errors were encountered and the document is valid.
A list of specific validation rules may be provided. If not provided, the default list of rules defined by the GraphQL specification will be used.
Each validation rules is a function which returns a visitor (see the language/visitor API). Visitor methods are expected to return GraphQLErrors, or Arrays of GraphQLErrors when invalid.
Validate will stop validation after a
maxErrors
limit has been reached. Attackers can send pathologically invalid queries to induce a DoS attack, so by defaultmaxErrors
set to 100 errors.Optionally a custom TypeInfo instance may be provided. If not provided, one will be created from the provided schema.
function validateSchema
validateSchema: (schema: GraphQLSchema) => ReadonlyArray<GraphQLError>;
Implements the "Type Validation" sub-sections of the specification's "Type System" section.
Validation runs synchronously, returning an array of encountered errors, or an empty array if no errors were encountered and the Schema is valid.
function valueFromAST
valueFromAST: ( valueNode: Maybe<ValueNode>, type: GraphQLInputType, variables?: Maybe<ObjMap<unknown>>) => unknown;
Produces a JavaScript value given a GraphQL Value AST.
A GraphQL type must be provided, which will be used to interpret different GraphQL Value literals.
Returns
undefined
when the value could not be validly coerced according to the provided type.| GraphQL Value | JSON Value | | -------------------- | ------------- | | Input Object | Object | | List | Array | | Boolean | Boolean | | String | String | | Int / Float | Number | | Enum Value | Unknown | | NullValue | null |
function valueFromASTUntyped
valueFromASTUntyped: ( valueNode: ValueNode, variables?: Maybe<ObjMap<unknown>>) => unknown;
Produces a JavaScript value given a GraphQL Value AST.
Unlike
valueFromAST()
, no type is provided. The resulting JavaScript value will reflect the provided GraphQL value AST.| GraphQL Value | JavaScript Value | | -------------------- | ---------------- | | Input Object | Object | | List | Array | | Boolean | Boolean | | String / Enum | String | | Int / Float | Number | | Null | null |
function ValuesOfCorrectTypeRule
ValuesOfCorrectTypeRule: (context: ValidationContext) => ASTVisitor;
Value literals of correct type
A GraphQL document is only valid if all value literals are of the type expected at their position.
See https://spec.graphql.org/draft/#sec-Values-of-Correct-Type
function VariablesAreInputTypesRule
VariablesAreInputTypesRule: (context: ValidationContext) => ASTVisitor;
Variables are input types
A GraphQL operation is only valid if all the variables it defines are of input types (scalar, enum, or input object).
See https://spec.graphql.org/draft/#sec-Variables-Are-Input-Types
function VariablesInAllowedPositionRule
VariablesInAllowedPositionRule: (context: ValidationContext) => ASTVisitor;
Variables in allowed position
Variable usages must be compatible with the arguments they are passed to.
See https://spec.graphql.org/draft/#sec-All-Variable-Usages-are-Allowed
function visit
visit: { <N extends ASTNode>( root: N, visitor: ASTVisitor, visitorKeys?: ASTVisitorKeyMap ): N; <R>(root: ASTNode, visitor: ASTReducer<R>, visitorKeys?: ASTVisitorKeyMap): R;};
visit() will walk through an AST using a depth-first traversal, calling the visitor's enter function at each node in the traversal, and calling the leave function after visiting that node and all of its child nodes.
By returning different values from the enter and leave functions, the behavior of the visitor can be altered, including skipping over a sub-tree of the AST (by returning false), editing the AST by returning a value or null to remove the value, or to stop the whole traversal by returning BREAK.
When using visit() to edit an AST, the original AST will not be modified, and a new version of the AST with the changes applied will be returned from the visit function.
const editedAST = visit(ast, {enter(node, key, parent, path, ancestors) {// @return// undefined: no action// false: skip visiting this node// visitor.BREAK: stop visiting altogether// null: delete this node// any value: replace this node with the returned value},leave(node, key, parent, path, ancestors) {// @return// undefined: no action// false: no action// visitor.BREAK: stop visiting altogether// null: delete this node// any value: replace this node with the returned value}});Alternatively to providing enter() and leave() functions, a visitor can instead provide functions named the same as the kinds of AST nodes, or enter/leave visitors at a named key, leading to three permutations of the visitor API:
1) Named visitors triggered when entering a node of a specific kind.
visit(ast, {Kind(node) {// enter the "Kind" node}})2) Named visitors that trigger upon entering and leaving a node of a specific kind.
visit(ast, {Kind: {enter(node) {// enter the "Kind" node}leave(node) {// leave the "Kind" node}}})3) Generic visitors that trigger upon entering and leaving any node.
visit(ast, {enter(node) {// enter any node},leave(node) {// leave any node}})
function visitInParallel
visitInParallel: (visitors: ReadonlyArray<ASTVisitor>) => ASTVisitor;
Creates a new visitor instance which delegates to many visitors to run in parallel. Each visitor will be visited for each node before moving on.
If a prior visitor edits a node, no following visitors will see that node.
function visitWithTypeInfo
visitWithTypeInfo: (typeInfo: TypeInfo, visitor: ASTVisitor) => ASTVisitor;
Creates a new visitor instance which maintains a provided TypeInfo instance along with visiting visitor.
Classes
class GraphQLDirective
class GraphQLDirective {}
Directives are used by the GraphQL runtime as a way of modifying execution behavior. Type system creators will usually not create these directly.
constructor
constructor(config: Readonly<GraphQLDirectiveConfig>);
property [Symbol.toStringTag]
readonly [Symbol.toStringTag]: string;
property args
args: readonly GraphQLArgument[];
property astNode
astNode: DirectiveDefinitionNode;
property description
description: string;
property extensions
extensions: Readonly<GraphQLDirectiveExtensions>;
property isRepeatable
isRepeatable: boolean;
property locations
locations: readonly DirectiveLocation[];
property name
name: string;
method toConfig
toConfig: () => GraphQLDirectiveNormalizedConfig;
method toJSON
toJSON: () => string;
method toString
toString: () => string;
class GraphQLEnumType
class 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
constructor(config: Readonly<GraphQLEnumTypeConfig>);
property [Symbol.toStringTag]
readonly [Symbol.toStringTag]: string;
property astNode
astNode: EnumTypeDefinitionNode;
property description
description: string;
property extensionASTNodes
extensionASTNodes: readonly EnumTypeExtensionNode[];
property extensions
extensions: Readonly<GraphQLEnumTypeExtensions>;
property name
name: string;
method getValue
getValue: (name: string) => Maybe<GraphQLEnumValue>;
method getValues
getValues: () => ReadonlyArray<GraphQLEnumValue>;
method parseLiteral
parseLiteral: ( valueNode: ValueNode, _variables: Maybe<ObjMap<unknown>>) => Maybe<any>;
method parseValue
parseValue: (inputValue: unknown) => Maybe<any>;
method serialize
serialize: (outputValue: unknown) => Maybe<string>;
method toConfig
toConfig: () => GraphQLEnumTypeNormalizedConfig;
method toJSON
toJSON: () => string;
method toString
toString: () => string;
class GraphQLError
class GraphQLError extends Error {}
A GraphQLError describes an Error found during the parse, validate, or execute phases of performing a GraphQL operation. In addition to a message and stack trace, it also includes information about the locations in a GraphQL document and/or execution result that correspond to the Error.
constructor
constructor(message: string, options?: GraphQLErrorOptions);
constructor
constructor( message: string, nodes?: ASTNode | readonly ASTNode[], source?: Source, positions?: readonly number[], path?: readonly (string | number)[], originalError?: Error & { readonly extensions?: unknown }, extensions?: GraphQLErrorExtensions);
Deprecated
Please use the
GraphQLErrorOptions
constructor overload instead.
property [Symbol.toStringTag]
readonly [Symbol.toStringTag]: string;
property extensions
readonly extensions: GraphQLErrorExtensions;
Extension fields to add to the formatted error.
property locations
readonly locations: readonly SourceLocation[];
An array of
{ line, column }
locations within the source GraphQL document which correspond to this error.Errors during validation often contain multiple locations, for example to point out two things with the same name. Errors during execution include a single location, the field which produced the error.
Enumerable, and appears in the result of JSON.stringify().
property nodes
readonly nodes: readonly ASTNode[];
An array of GraphQL AST Nodes corresponding to this error.
property originalError
readonly originalError: Error;
The original error thrown from a field resolver during execution.
property path
readonly path: readonly (string | number)[];
An array describing the JSON-path into the execution response which corresponds to this error. Only included for errors during execution.
Enumerable, and appears in the result of JSON.stringify().
property positions
readonly positions: readonly number[];
An array of character offsets within the source GraphQL document which correspond to this error.
property source
readonly source: Source;
The source GraphQL document for the first location of this error.
Note that if this Error represents more than one node, the source may not represent nodes after the first node.
method toJSON
toJSON: () => GraphQLFormattedError;
method toString
toString: () => string;
class GraphQLInputObjectType
class 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 queryExample:
const GeoPoint = new GraphQLInputObjectType({name: 'GeoPoint',fields: {lat: { type: new GraphQLNonNull(GraphQLFloat) },lon: { type: new GraphQLNonNull(GraphQLFloat) },alt: { type: GraphQLFloat, defaultValue: 0 },}});
constructor
constructor(config: Readonly<GraphQLInputObjectTypeConfig>);
property [Symbol.toStringTag]
readonly [Symbol.toStringTag]: string;
property astNode
astNode: InputObjectTypeDefinitionNode;
property description
description: string;
property extensionASTNodes
extensionASTNodes: readonly InputObjectTypeExtensionNode[];
property extensions
extensions: Readonly<GraphQLInputObjectTypeExtensions>;
property isOneOf
isOneOf: boolean;
property name
name: string;
method getFields
getFields: () => GraphQLInputFieldMap;
method toConfig
toConfig: () => GraphQLInputObjectTypeNormalizedConfig;
method toJSON
toJSON: () => string;
method toString
toString: () => string;
class GraphQLInterfaceType
class 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
constructor(config: Readonly<GraphQLInterfaceTypeConfig<any, any>>);
property [Symbol.toStringTag]
readonly [Symbol.toStringTag]: string;
property astNode
astNode: InterfaceTypeDefinitionNode;
property description
description: string;
property extensionASTNodes
extensionASTNodes: readonly InterfaceTypeExtensionNode[];
property extensions
extensions: Readonly<GraphQLInterfaceTypeExtensions>;
property name
name: string;
property resolveType
resolveType: GraphQLTypeResolver<any, any>;
method getFields
getFields: () => GraphQLFieldMap<any, any>;
method getInterfaces
getInterfaces: () => ReadonlyArray<GraphQLInterfaceType>;
method toConfig
toConfig: () => GraphQLInterfaceTypeNormalizedConfig;
method toJSON
toJSON: () => string;
method toString
toString: () => string;
class GraphQLList
class GraphQLList<T extends GraphQLType> {}
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) },})})
constructor
constructor(ofType: GraphQLType);
property [Symbol.toStringTag]
readonly [Symbol.toStringTag]: string;
property ofType
readonly ofType: GraphQLType;
method toJSON
toJSON: () => string;
method toString
toString: () => string;
class GraphQLNonNull
class GraphQLNonNull<T extends GraphQLNullableType> {}
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.
constructor
constructor(ofType: GraphQLNullableType);
property [Symbol.toStringTag]
readonly [Symbol.toStringTag]: string;
property ofType
readonly ofType: GraphQLNullableType;
method toJSON
toJSON: () => string;
method toString
toString: () => string;
class GraphQLObjectType
class GraphQLObjectType<TSource = any, TContext = any> {}
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 },})});
constructor
constructor(config: Readonly<GraphQLObjectTypeConfig<TSource, TContext>>);
property [Symbol.toStringTag]
readonly [Symbol.toStringTag]: string;
property astNode
astNode: ObjectTypeDefinitionNode;
property description
description: string;
property extensionASTNodes
extensionASTNodes: readonly ObjectTypeExtensionNode[];
property extensions
extensions: Readonly<GraphQLObjectTypeExtensions<TSource, TContext>>;
property isTypeOf
isTypeOf: GraphQLIsTypeOfFn<TSource, TContext>;
property name
name: string;
method getFields
getFields: () => GraphQLFieldMap<TSource, TContext>;
method getInterfaces
getInterfaces: () => ReadonlyArray<GraphQLInterfaceType>;
method toConfig
toConfig: () => GraphQLObjectTypeNormalizedConfig<TSource, TContext>;
method toJSON
toJSON: () => string;
method toString
toString: () => string;
class GraphQLScalarType
class GraphQLScalarType<TInternal = unknown, TExternal = TInternal> {}
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 returnsundefined
) then an error will be raised and anull
value will be returned in the response. It is always better to validateExample:
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;}});
constructor
constructor(config: Readonly<GraphQLScalarTypeConfig<TInternal, TExternal>>);
property [Symbol.toStringTag]
readonly [Symbol.toStringTag]: string;
property astNode
astNode: ScalarTypeDefinitionNode;
property description
description: string;
property extensionASTNodes
extensionASTNodes: readonly ScalarTypeExtensionNode[];
property extensions
extensions: Readonly<GraphQLScalarTypeExtensions>;
property name
name: string;
property parseLiteral
parseLiteral: GraphQLScalarLiteralParser<TInternal>;
property parseValue
parseValue: GraphQLScalarValueParser<TInternal>;
property serialize
serialize: GraphQLScalarSerializer<TExternal>;
property specifiedByURL
specifiedByURL: string;
method toConfig
toConfig: () => GraphQLScalarTypeNormalizedConfig<TInternal, TExternal>;
method toJSON
toJSON: () => string;
method toString
toString: () => string;
class GraphQLSchema
class GraphQLSchema {}
Schema Definition
A Schema is created by supplying the root types of each type of operation, query and mutation (optional). A schema definition is then supplied to the validator and executor.
Example:
const MyAppSchema = new GraphQLSchema({query: MyAppQueryRootType,mutation: MyAppMutationRootType,})Note: When the schema is constructed, by default only the types that are reachable by traversing the root types are included, other types must be explicitly referenced.
Example:
const characterInterface = new GraphQLInterfaceType({name: 'Character',...});const humanType = new GraphQLObjectType({name: 'Human',interfaces: [characterInterface],...});const droidType = new GraphQLObjectType({name: 'Droid',interfaces: [characterInterface],...});const schema = new GraphQLSchema({query: new GraphQLObjectType({name: 'Query',fields: {hero: { type: characterInterface, ... },}}),...// Since this schema references only the `Character` interface it's// necessary to explicitly list the types that implement it if// you want them to be included in the final schema.types: [humanType, droidType],})Note: If an array of
directives
are provided to GraphQLSchema, that will be the exact list of directives represented and allowed. Ifdirectives
is not provided then a default set of the specified directives (e.g.@include
and@skip
) will be used. If you wish to provide *additional* directives to these specified directives, you must explicitly declare them. Example:const MyAppSchema = new GraphQLSchema({...directives: specifiedDirectives.concat([ myCustomDirective ]),})
constructor
constructor(config: Readonly<GraphQLSchemaConfig>);
property [Symbol.toStringTag]
readonly [Symbol.toStringTag]: string;
property astNode
astNode: SchemaDefinitionNode;
property description
description: string;
property extensionASTNodes
extensionASTNodes: readonly SchemaExtensionNode[];
property extensions
extensions: Readonly<GraphQLSchemaExtensions>;
method getDirective
getDirective: (name: string) => Maybe<GraphQLDirective>;
method getDirectives
getDirectives: () => ReadonlyArray<GraphQLDirective>;
method getImplementations
getImplementations: (interfaceType: GraphQLInterfaceType) => { objects: ReadonlyArray<GraphQLObjectType>; interfaces: ReadonlyArray<GraphQLInterfaceType>;};
method getMutationType
getMutationType: () => Maybe<GraphQLObjectType>;
method getPossibleTypes
getPossibleTypes: ( abstractType: GraphQLAbstractType) => ReadonlyArray<GraphQLObjectType>;
method getQueryType
getQueryType: () => Maybe<GraphQLObjectType>;
method getRootType
getRootType: (operation: OperationTypeNode) => Maybe<GraphQLObjectType>;
method getSubscriptionType
getSubscriptionType: () => Maybe<GraphQLObjectType>;
method getType
getType: (name: string) => GraphQLNamedType | undefined;
method getTypeMap
getTypeMap: () => TypeMap;
method isSubType
isSubType: ( abstractType: GraphQLAbstractType, maybeSubType: GraphQLObjectType | GraphQLInterfaceType) => boolean;
method toConfig
toConfig: () => GraphQLSchemaNormalizedConfig;
class GraphQLUnionType
class 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
constructor(config: Readonly<GraphQLUnionTypeConfig<any, any>>);
property [Symbol.toStringTag]
readonly [Symbol.toStringTag]: string;
property astNode
astNode: UnionTypeDefinitionNode;
property description
description: string;
property extensionASTNodes
extensionASTNodes: readonly UnionTypeExtensionNode[];
property extensions
extensions: Readonly<GraphQLUnionTypeExtensions>;
property name
name: string;
property resolveType
resolveType: GraphQLTypeResolver<any, any>;
method getTypes
getTypes: () => ReadonlyArray<GraphQLObjectType>;
method toConfig
toConfig: () => GraphQLUnionTypeNormalizedConfig;
method toJSON
toJSON: () => string;
method toString
toString: () => string;
class Lexer
class Lexer {}
Given a Source object, creates a Lexer for that source. A Lexer is a stateful stream generator in that every time it is advanced, it returns the next token in the Source. Assuming the source lexes, the final Token emitted by the lexer will be of kind EOF, after which the lexer will repeatedly return the same EOF token whenever called.
constructor
constructor(source: Source);
property [Symbol.toStringTag]
readonly [Symbol.toStringTag]: string;
property lastToken
lastToken: Token;
The previously focused non-ignored token.
property line
line: number;
The (1-indexed) line containing the current token.
property lineStart
lineStart: number;
The character offset at which the current line begins.
property source
source: Source;
property token
token: Token;
The currently focused non-ignored token.
method advance
advance: () => Token;
Advances the token stream to the next non-ignored token.
method lookahead
lookahead: () => Token;
Looks ahead and returns the next non-ignored token, but does not change the state of Lexer.
class Location
class Location {}
Contains a range of UTF-8 character offsets and token references that identify the region of the source from which the AST derived.
constructor
constructor(startToken: Token, endToken: Token, source: Source);
property [Symbol.toStringTag]
readonly [Symbol.toStringTag]: string;
property end
readonly end: number;
The character offset at which this Node ends.
property endToken
readonly endToken: Token;
The Token at which this Node ends.
property source
readonly source: Source;
The Source document the AST represents.
property start
readonly start: number;
The character offset at which this Node begins.
property startToken
readonly startToken: Token;
The Token at which this Node begins.
method toJSON
toJSON: () => { start: number; end: number };
class Source
class Source {}
A representation of source input to GraphQL. The
name
andlocationOffset
parameters are optional, but they are useful for clients who store GraphQL documents in source files. For example, if the GraphQL input starts at line 40 in a file namedFoo.graphql
, it might be useful forname
to be"Foo.graphql"
and location to be{ line: 40, column: 1 }
. Theline
andcolumn
properties inlocationOffset
are 1-indexed.
constructor
constructor(body: string, name?: string, locationOffset?: Location);
property [Symbol.toStringTag]
readonly [Symbol.toStringTag]: string;
property body
body: string;
property locationOffset
locationOffset: Location;
property name
name: string;
class Token
class Token {}
Represents a range of characters represented by a lexical token within a Source.
constructor
constructor( kind: TokenKind, start: number, end: number, line: number, column: number, value?: string);
property [Symbol.toStringTag]
readonly [Symbol.toStringTag]: string;
property column
readonly column: number;
The 1-indexed column number at which this Token begins.
property end
readonly end: number;
The character offset at which this Node ends.
property kind
readonly kind: TokenKind;
The kind of Token.
property line
readonly line: number;
The 1-indexed line number on which this Token appears.
property next
readonly next: Token;
property prev
readonly prev: Token;
Tokens exist as nodes in a double-linked-list amongst all tokens including ignored tokens. is always the first node and the last.
property start
readonly start: number;
The character offset at which this Node begins.
property value
readonly value: string;
For non-punctuation tokens, represents the interpreted value of the token.
Note: is undefined for punctuation tokens, but typed as string for convenience in the parser.
method toJSON
toJSON: () => { kind: TokenKind; value?: string; line: number; column: number };
class TypeInfo
class TypeInfo {}
TypeInfo is a utility class which, given a GraphQL schema, can keep track of the current field and type definitions at any point in a GraphQL document AST during a recursive descent by calling
enter(node)
andleave(node)
.
constructor
constructor( schema: GraphQLSchema, initialType?: GraphQLType, getFieldDefFn?: GetFieldDefFn);
property [Symbol.toStringTag]
readonly [Symbol.toStringTag]: string;
method enter
enter: (node: ASTNode) => void;
method getArgument
getArgument: () => Maybe<GraphQLArgument>;
method getDefaultValue
getDefaultValue: () => Maybe<unknown>;
method getDirective
getDirective: () => Maybe<GraphQLDirective>;
method getEnumValue
getEnumValue: () => Maybe<GraphQLEnumValue>;
method getFieldDef
getFieldDef: () => GraphQLField<unknown, unknown, any>;
method getInputType
getInputType: () => Maybe<GraphQLInputType>;
method getParentInputType
getParentInputType: () => Maybe<GraphQLInputType>;
method getParentType
getParentType: () => Maybe<GraphQLCompositeType>;
method getType
getType: () => Maybe<GraphQLOutputType>;
method leave
leave: (node: ASTNode) => void;
class ValidationContext
class ValidationContext extends ASTValidationContext {}
constructor
constructor( schema: GraphQLSchema, ast: DocumentNode, typeInfo: TypeInfo, onError: (error: GraphQLError) => void);
property [Symbol.toStringTag]
readonly [Symbol.toStringTag]: string;
method getArgument
getArgument: () => Maybe<GraphQLArgument>;
method getDirective
getDirective: () => Maybe<GraphQLDirective>;
method getEnumValue
getEnumValue: () => Maybe<GraphQLEnumValue>;
method getFieldDef
getFieldDef: () => GraphQLField<unknown, unknown, any>;
method getInputType
getInputType: () => Maybe<GraphQLInputType>;
method getParentInputType
getParentInputType: () => Maybe<GraphQLInputType>;
method getParentType
getParentType: () => Maybe<GraphQLCompositeType>;
method getRecursiveVariableUsages
getRecursiveVariableUsages: ( operation: OperationDefinitionNode) => ReadonlyArray<VariableUsage>;
method getSchema
getSchema: () => GraphQLSchema;
method getType
getType: () => Maybe<GraphQLOutputType>;
method getVariableUsages
getVariableUsages: (node: NodeWithSelectionSet) => ReadonlyArray<VariableUsage>;
Interfaces
interface ArgumentNode
interface ArgumentNode {}
interface BooleanValueNode
interface BooleanValueNode {}
interface BreakingChange
interface BreakingChange {}
property description
description: string;
property type
type: BreakingChangeType;
interface BuildSchemaOptions
interface BuildSchemaOptions extends GraphQLSchemaValidationOptions {}
property assumeValidSDL
assumeValidSDL?: boolean;
Set to true to assume the SDL is valid.
Default: false
interface ConstArgumentNode
interface ConstArgumentNode {}
interface ConstDirectiveNode
interface ConstDirectiveNode {}
interface ConstListValueNode
interface ConstListValueNode {}
interface ConstObjectFieldNode
interface ConstObjectFieldNode {}
interface ConstObjectValueNode
interface ConstObjectValueNode {}
interface DangerousChange
interface DangerousChange {}
property description
description: string;
property type
type: DangerousChangeType;
interface DirectiveDefinitionNode
interface DirectiveDefinitionNode {}
Directive Definitions
property arguments
readonly arguments?: ReadonlyArray<InputValueDefinitionNode>;
property description
readonly description?: StringValueNode;
property kind
readonly kind: Kind.DIRECTIVE_DEFINITION;
property loc
readonly loc?: Location;
property locations
readonly locations: ReadonlyArray<NameNode>;
property name
readonly name: NameNode;
property repeatable
readonly repeatable: boolean;
interface DirectiveNode
interface DirectiveNode {}
Directives
interface DocumentNode
interface DocumentNode {}
Document
property definitions
readonly definitions: ReadonlyArray<DefinitionNode>;
property kind
readonly kind: Kind.DOCUMENT;
property loc
readonly loc?: Location;
property tokenCount
readonly tokenCount?: number | undefined;
interface EnumTypeDefinitionNode
interface EnumTypeDefinitionNode {}
property description
readonly description?: StringValueNode;
property directives
readonly directives?: ReadonlyArray<ConstDirectiveNode>;
property kind
readonly kind: Kind.ENUM_TYPE_DEFINITION;
property loc
readonly loc?: Location;
property name
readonly name: NameNode;
property values
readonly values?: ReadonlyArray<EnumValueDefinitionNode>;
interface EnumTypeExtensionNode
interface EnumTypeExtensionNode {}
property directives
readonly directives?: ReadonlyArray<ConstDirectiveNode>;
property kind
readonly kind: Kind.ENUM_TYPE_EXTENSION;
property loc
readonly loc?: Location;
property name
readonly name: NameNode;
property values
readonly values?: ReadonlyArray<EnumValueDefinitionNode>;
interface EnumValueDefinitionNode
interface EnumValueDefinitionNode {}
property description
readonly description?: StringValueNode;
property directives
readonly directives?: ReadonlyArray<ConstDirectiveNode>;
property kind
readonly kind: Kind.ENUM_VALUE_DEFINITION;
property loc
readonly loc?: Location;
property name
readonly name: NameNode;
interface EnumValueNode
interface EnumValueNode {}
interface ExecutionArgs
interface ExecutionArgs {}
property contextValue
contextValue?: unknown;
property document
document: DocumentNode;
property fieldResolver
fieldResolver?: Maybe<GraphQLFieldResolver<any, any>>;
property operationName
operationName?: Maybe<string>;
property rootValue
rootValue?: unknown;
property schema
schema: GraphQLSchema;
property subscribeFieldResolver
subscribeFieldResolver?: Maybe<GraphQLFieldResolver<any, any>>;
property typeResolver
typeResolver?: Maybe<GraphQLTypeResolver<any, any>>;
property variableValues
variableValues?: Maybe<{ readonly [variable: string]: unknown;}>;
interface ExecutionResult
interface ExecutionResult<TData = ObjMap<unknown>, TExtensions = ObjMap<unknown>> {}
The result of GraphQL execution.
-
errors
is included when any errors occurred as a non-empty array. -data
is the result of a successful execution of the query. -extensions
is reserved for adding non-standard properties.
property data
data?: TData | null;
property errors
errors?: ReadonlyArray<GraphQLError>;
property extensions
extensions?: TExtensions;
interface FieldDefinitionNode
interface FieldDefinitionNode {}
property arguments
readonly arguments?: ReadonlyArray<InputValueDefinitionNode>;
property description
readonly description?: StringValueNode;
property directives
readonly directives?: ReadonlyArray<ConstDirectiveNode>;
property kind
readonly kind: Kind.FIELD_DEFINITION;
property loc
readonly loc?: Location;
property name
readonly name: NameNode;
property type
readonly type: TypeNode;
interface FieldNode
interface FieldNode {}
property alias
readonly alias?: NameNode;
property arguments
readonly arguments?: ReadonlyArray<ArgumentNode>;
property directives
readonly directives?: ReadonlyArray<DirectiveNode>;
property kind
readonly kind: Kind.FIELD;
property loc
readonly loc?: Location;
property name
readonly name: NameNode;
property selectionSet
readonly selectionSet?: SelectionSetNode;
interface FloatValueNode
interface FloatValueNode {}
interface FormattedExecutionResult
interface FormattedExecutionResult< TData = ObjMap<unknown>, TExtensions = ObjMap<unknown>> {}
property data
data?: TData | null;
property errors
errors?: ReadonlyArray<GraphQLFormattedError>;
property extensions
extensions?: TExtensions;
interface FragmentDefinitionNode
interface FragmentDefinitionNode {}
property directives
readonly directives?: ReadonlyArray<DirectiveNode>;
property kind
readonly kind: Kind.FRAGMENT_DEFINITION;
property loc
readonly loc?: Location;
property name
readonly name: NameNode;
property selectionSet
readonly selectionSet: SelectionSetNode;
property typeCondition
readonly typeCondition: NamedTypeNode;
property variableDefinitions
readonly variableDefinitions?: ReadonlyArray<VariableDefinitionNode>;
Deprecated
variableDefinitions will be removed in v17.0.0
interface FragmentSpreadNode
interface FragmentSpreadNode {}
Fragments
property directives
readonly directives?: ReadonlyArray<DirectiveNode>;
property kind
readonly kind: Kind.FRAGMENT_SPREAD;
property loc
readonly loc?: Location;
property name
readonly name: NameNode;
interface GraphQLArgs
interface GraphQLArgs {}
This is the primary entry point function for fulfilling GraphQL operations by parsing, validating, and executing a GraphQL document along side a GraphQL schema.
More sophisticated GraphQL servers, such as those which persist queries, may wish to separate the validation and execution phases to a static time tooling step, and a server runtime step.
Accepts either an object with named arguments, or individual arguments:
schema: The GraphQL type system to use when validating and executing a query. source: A GraphQL language formatted string representing the requested operation. rootValue: The value provided as the first argument to resolver functions on the top level type (e.g. the query object type). contextValue: The context value is provided as an argument to resolver functions after field arguments. It is used to pass shared information useful at any point during executing this query, for example the currently logged in user and connections to databases or other services. variableValues: A mapping of variable name to runtime value to use for all variables defined in the requestString. operationName: The name of the operation to use if requestString contains multiple possible operations. Can be omitted if requestString contains only one operation. fieldResolver: A resolver function to use when one is not provided by the schema. If not provided, the default field resolver is used (which looks for a value or method on the source value with the field's name). typeResolver: A type resolver function to use when none is provided by the schema. If not provided, the default type resolver is used (which looks for a
__typename
field or alternatively calls theisTypeOf
method).
property contextValue
contextValue?: unknown;
property fieldResolver
fieldResolver?: Maybe<GraphQLFieldResolver<any, any>>;
property operationName
operationName?: Maybe<string>;
property rootValue
rootValue?: unknown;
property schema
schema: GraphQLSchema;
property source
source: string | Source;
property typeResolver
typeResolver?: Maybe<GraphQLTypeResolver<any, any>>;
property variableValues
variableValues?: Maybe<{ readonly [variable: string]: unknown;}>;
interface GraphQLArgument
interface GraphQLArgument {}
property astNode
astNode: Maybe<InputValueDefinitionNode>;
property defaultValue
defaultValue: unknown;
property deprecationReason
deprecationReason: Maybe<string>;
property description
description: Maybe<string>;
property extensions
extensions: Readonly<GraphQLArgumentExtensions>;
property name
name: string;
property type
type: GraphQLInputType;
interface GraphQLArgumentConfig
interface GraphQLArgumentConfig {}
property astNode
astNode?: Maybe<InputValueDefinitionNode>;
property defaultValue
defaultValue?: unknown;
property deprecationReason
deprecationReason?: Maybe<string>;
property description
description?: Maybe<string>;
property extensions
extensions?: Maybe<Readonly<GraphQLArgumentExtensions>>;
property type
type: GraphQLInputType;
interface GraphQLArgumentExtensions
interface GraphQLArgumentExtensions {}
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.
index signature
[attributeName: string]: unknown;
interface GraphQLDirectiveConfig
interface GraphQLDirectiveConfig {}
property args
args?: Maybe<GraphQLFieldConfigArgumentMap>;
property astNode
astNode?: Maybe<DirectiveDefinitionNode>;
property description
description?: Maybe<string>;
property extensions
extensions?: Maybe<Readonly<GraphQLDirectiveExtensions>>;
property isRepeatable
isRepeatable?: Maybe<boolean>;
property locations
locations: ReadonlyArray<DirectiveLocation>;
property name
name: string;
interface GraphQLDirectiveExtensions
interface GraphQLDirectiveExtensions {}
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.
index signature
[attributeName: string]: unknown;
interface GraphQLEnumTypeConfig
interface GraphQLEnumTypeConfig {}
property astNode
astNode?: Maybe<EnumTypeDefinitionNode>;
property description
description?: Maybe<string>;
property extensionASTNodes
extensionASTNodes?: Maybe<ReadonlyArray<EnumTypeExtensionNode>>;
property extensions
extensions?: Maybe<Readonly<GraphQLEnumTypeExtensions>>;
property name
name: string;
property values
values: ThunkObjMap<GraphQLEnumValueConfig>;
interface GraphQLEnumTypeExtensions
interface GraphQLEnumTypeExtensions {}
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.
index signature
[attributeName: string]: unknown;
interface GraphQLEnumValue
interface GraphQLEnumValue {}
property astNode
astNode: Maybe<EnumValueDefinitionNode>;
property deprecationReason
deprecationReason: Maybe<string>;
property description
description: Maybe<string>;
property extensions
extensions: Readonly<GraphQLEnumValueExtensions>;
property name
name: string;
property value
value: any;
interface GraphQLEnumValueConfig
interface GraphQLEnumValueConfig {}
property astNode
astNode?: Maybe<EnumValueDefinitionNode>;
property deprecationReason
deprecationReason?: Maybe<string>;
property description
description?: Maybe<string>;
property extensions
extensions?: Maybe<Readonly<GraphQLEnumValueExtensions>>;
property value
value?: any;
interface GraphQLEnumValueExtensions
interface GraphQLEnumValueExtensions {}
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.
index signature
[attributeName: string]: unknown;
interface GraphQLErrorExtensions
interface GraphQLErrorExtensions {}
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.
index signature
[attributeName: string]: unknown;
interface GraphQLErrorOptions
interface GraphQLErrorOptions {}
property extensions
extensions?: Maybe<GraphQLErrorExtensions>;
property nodes
nodes?: ReadonlyArray<ASTNode> | ASTNode | null;
property originalError
originalError?: Maybe< Error & { readonly extensions?: unknown; }>;
property path
path?: Maybe<ReadonlyArray<string | number>>;
property positions
positions?: Maybe<ReadonlyArray<number>>;
property source
source?: Maybe<Source>;
interface GraphQLField
interface GraphQLField<TSource, TContext, TArgs = any> {}
property args
args: ReadonlyArray<GraphQLArgument>;
property astNode
astNode: Maybe<FieldDefinitionNode>;
property deprecationReason
deprecationReason: Maybe<string>;
property description
description: Maybe<string>;
property extensions
extensions: Readonly<GraphQLFieldExtensions<TSource, TContext, TArgs>>;
property name
name: string;
property resolve
resolve?: GraphQLFieldResolver<TSource, TContext, TArgs>;
property subscribe
subscribe?: GraphQLFieldResolver<TSource, TContext, TArgs>;
property type
type: GraphQLOutputType;
interface GraphQLFieldConfig
interface GraphQLFieldConfig<TSource, TContext, TArgs = any> {}
property args
args?: GraphQLFieldConfigArgumentMap;
property astNode
astNode?: Maybe<FieldDefinitionNode>;
property deprecationReason
deprecationReason?: Maybe<string>;
property description
description?: Maybe<string>;
property extensions
extensions?: Maybe<Readonly<GraphQLFieldExtensions<TSource, TContext, TArgs>>>;
property resolve
resolve?: GraphQLFieldResolver<TSource, TContext, TArgs>;
property subscribe
subscribe?: GraphQLFieldResolver<TSource, TContext, TArgs>;
property type
type: GraphQLOutputType;
interface GraphQLFieldExtensions
interface GraphQLFieldExtensions<_TSource, _TContext, _TArgs = any> {}
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.
index signature
[attributeName: string]: unknown;
interface GraphQLFormattedError
interface GraphQLFormattedError {}
See: https://spec.graphql.org/draft/#sec-Errors
property extensions
readonly extensions?: GraphQLFormattedErrorExtensions;
Reserved for implementors to extend the protocol however they see fit, and hence there are no additional restrictions on its contents.
property locations
readonly locations?: ReadonlyArray<SourceLocation>;
If an error can be associated to a particular point in the requested GraphQL document, it should contain a list of locations.
property message
readonly message: string;
A short, human-readable summary of the problem that **SHOULD NOT** change from occurrence to occurrence of the problem, except for purposes of localization.
property path
readonly path?: ReadonlyArray<string | number>;
If an error can be associated to a particular field in the GraphQL result, it _must_ contain an entry with the key
path
that details the path of the response field which experienced the error. This allows clients to identify whether a null result is intentional or caused by a runtime error.
interface GraphQLFormattedErrorExtensions
interface GraphQLFormattedErrorExtensions {}
Custom formatted 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.
index signature
[attributeName: string]: unknown;
interface GraphQLInputField
interface GraphQLInputField {}
property astNode
astNode: Maybe<InputValueDefinitionNode>;
property defaultValue
defaultValue: unknown;
property deprecationReason
deprecationReason: Maybe<string>;
property description
description: Maybe<string>;
property extensions
extensions: Readonly<GraphQLInputFieldExtensions>;
property name
name: string;
property type
type: GraphQLInputType;
interface GraphQLInputFieldConfig
interface GraphQLInputFieldConfig {}
property astNode
astNode?: Maybe<InputValueDefinitionNode>;
property defaultValue
defaultValue?: unknown;
property deprecationReason
deprecationReason?: Maybe<string>;
property description
description?: Maybe<string>;
property extensions
extensions?: Maybe<Readonly<GraphQLInputFieldExtensions>>;
property type
type: GraphQLInputType;
interface GraphQLInputFieldExtensions
interface GraphQLInputFieldExtensions {}
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.
index signature
[attributeName: string]: unknown;
interface GraphQLInputObjectTypeConfig
interface GraphQLInputObjectTypeConfig {}
property astNode
astNode?: Maybe<InputObjectTypeDefinitionNode>;
property description
description?: Maybe<string>;
property extensionASTNodes
extensionASTNodes?: Maybe<ReadonlyArray<InputObjectTypeExtensionNode>>;
property extensions
extensions?: Maybe<Readonly<GraphQLInputObjectTypeExtensions>>;
property fields
fields: ThunkObjMap<GraphQLInputFieldConfig>;
property isOneOf
isOneOf?: boolean;
property name
name: string;
interface GraphQLInputObjectTypeExtensions
interface GraphQLInputObjectTypeExtensions {}
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.
index signature
[attributeName: string]: unknown;
interface GraphQLInterfaceTypeConfig
interface GraphQLInterfaceTypeConfig<TSource, TContext> {}
property astNode
astNode?: Maybe<InterfaceTypeDefinitionNode>;
property description
description?: Maybe<string>;
property extensionASTNodes
extensionASTNodes?: Maybe<ReadonlyArray<InterfaceTypeExtensionNode>>;
property extensions
extensions?: Maybe<Readonly<GraphQLInterfaceTypeExtensions>>;
property fields
fields: ThunkObjMap<GraphQLFieldConfig<TSource, TContext>>;
property interfaces
interfaces?: ThunkReadonlyArray<GraphQLInterfaceType>;
property name
name: string;
property resolveType
resolveType?: Maybe<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.
interface GraphQLInterfaceTypeExtensions
interface GraphQLInterfaceTypeExtensions {}
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.
index signature
[attributeName: string]: unknown;
interface GraphQLObjectTypeConfig
interface GraphQLObjectTypeConfig<TSource, TContext> {}
property astNode
astNode?: Maybe<ObjectTypeDefinitionNode>;
property description
description?: Maybe<string>;
property extensionASTNodes
extensionASTNodes?: Maybe<ReadonlyArray<ObjectTypeExtensionNode>>;
property extensions
extensions?: Maybe<Readonly<GraphQLObjectTypeExtensions<TSource, TContext>>>;
property fields
fields: ThunkObjMap<GraphQLFieldConfig<TSource, TContext>>;
property interfaces
interfaces?: ThunkReadonlyArray<GraphQLInterfaceType>;
property isTypeOf
isTypeOf?: Maybe<GraphQLIsTypeOfFn<TSource, TContext>>;
property name
name: string;
interface GraphQLObjectTypeExtensions
interface GraphQLObjectTypeExtensions<_TSource = any, _TContext = any> {}
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.
index signature
[attributeName: string]: unknown;
interface GraphQLResolveInfo
interface GraphQLResolveInfo {}
property fieldName
readonly fieldName: string;
property fieldNodes
readonly fieldNodes: ReadonlyArray<FieldNode>;
property fragments
readonly fragments: ObjMap<FragmentDefinitionNode>;
property operation
readonly operation: OperationDefinitionNode;
property parentType
readonly parentType: GraphQLObjectType;
property path
readonly path: Path;
property returnType
readonly returnType: GraphQLOutputType;
property rootValue
readonly rootValue: unknown;
property schema
readonly schema: GraphQLSchema;
property variableValues
readonly variableValues: { [variable: string]: unknown;};
interface GraphQLScalarTypeConfig
interface GraphQLScalarTypeConfig<TInternal, TExternal> {}
property astNode
astNode?: Maybe<ScalarTypeDefinitionNode>;
property description
description?: Maybe<string>;
property extensionASTNodes
extensionASTNodes?: Maybe<ReadonlyArray<ScalarTypeExtensionNode>>;
property extensions
extensions?: Maybe<Readonly<GraphQLScalarTypeExtensions>>;
property name
name: string;
property parseLiteral
parseLiteral?: GraphQLScalarLiteralParser<TInternal>;
Parses an externally provided literal value to use as an input.
property parseValue
parseValue?: GraphQLScalarValueParser<TInternal>;
Parses an externally provided value to use as an input.
property serialize
serialize?: GraphQLScalarSerializer<TExternal>;
Serializes an internal value to include in a response.
property specifiedByURL
specifiedByURL?: Maybe<string>;
interface GraphQLScalarTypeExtensions
interface GraphQLScalarTypeExtensions {}
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.
index signature
[attributeName: string]: unknown;
interface GraphQLSchemaConfig
interface GraphQLSchemaConfig extends GraphQLSchemaValidationOptions {}
property astNode
astNode?: Maybe<SchemaDefinitionNode>;
property description
description?: Maybe<string>;
property directives
directives?: Maybe<ReadonlyArray<GraphQLDirective>>;
property extensionASTNodes
extensionASTNodes?: Maybe<ReadonlyArray<SchemaExtensionNode>>;
property extensions
extensions?: Maybe<Readonly<GraphQLSchemaExtensions>>;
property mutation
mutation?: Maybe<GraphQLObjectType>;
property query
query?: Maybe<GraphQLObjectType>;
property subscription
subscription?: Maybe<GraphQLObjectType>;
property types
types?: Maybe<ReadonlyArray<GraphQLNamedType>>;
interface GraphQLSchemaExtensions
interface GraphQLSchemaExtensions {}
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.
index signature
[attributeName: string]: unknown;
interface GraphQLUnionTypeConfig
interface GraphQLUnionTypeConfig<TSource, TContext> {}
property astNode
astNode?: Maybe<UnionTypeDefinitionNode>;
property description
description?: Maybe<string>;
property extensionASTNodes
extensionASTNodes?: Maybe<ReadonlyArray<UnionTypeExtensionNode>>;
property extensions
extensions?: Maybe<Readonly<GraphQLUnionTypeExtensions>>;
property name
name: string;
property resolveType
resolveType?: Maybe<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.
property types
types: ThunkReadonlyArray<GraphQLObjectType>;
interface GraphQLUnionTypeExtensions
interface GraphQLUnionTypeExtensions {}
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.
index signature
[attributeName: string]: unknown;
interface InlineFragmentNode
interface InlineFragmentNode {}
property directives
readonly directives?: ReadonlyArray<DirectiveNode>;
property kind
readonly kind: Kind.INLINE_FRAGMENT;
property loc
readonly loc?: Location;
property selectionSet
readonly selectionSet: SelectionSetNode;
property typeCondition
readonly typeCondition?: NamedTypeNode;
interface InputObjectTypeDefinitionNode
interface InputObjectTypeDefinitionNode {}
property description
readonly description?: StringValueNode;
property directives
readonly directives?: ReadonlyArray<ConstDirectiveNode>;
property fields
readonly fields?: ReadonlyArray<InputValueDefinitionNode>;
property kind
readonly kind: Kind.INPUT_OBJECT_TYPE_DEFINITION;
property loc
readonly loc?: Location;
property name
readonly name: NameNode;
interface InputObjectTypeExtensionNode
interface InputObjectTypeExtensionNode {}
property directives
readonly directives?: ReadonlyArray<ConstDirectiveNode>;
property fields
readonly fields?: ReadonlyArray<InputValueDefinitionNode>;
property kind
readonly kind: Kind.INPUT_OBJECT_TYPE_EXTENSION;
property loc
readonly loc?: Location;
property name
readonly name: NameNode;
interface InputValueDefinitionNode
interface InputValueDefinitionNode {}
property defaultValue
readonly defaultValue?: ConstValueNode;
property description
readonly description?: StringValueNode;
property directives
readonly directives?: ReadonlyArray<ConstDirectiveNode>;
property kind
readonly kind: Kind.INPUT_VALUE_DEFINITION;
property loc
readonly loc?: Location;
property name
readonly name: NameNode;
property type
readonly type: TypeNode;
interface InterfaceTypeDefinitionNode
interface InterfaceTypeDefinitionNode {}
property description
readonly description?: StringValueNode;
property directives
readonly directives?: ReadonlyArray<ConstDirectiveNode>;
property fields
readonly fields?: ReadonlyArray<FieldDefinitionNode>;
property interfaces
readonly interfaces?: ReadonlyArray<NamedTypeNode>;
property kind
readonly kind: Kind.INTERFACE_TYPE_DEFINITION;
property loc
readonly loc?: Location;
property name
readonly name: NameNode;
interface InterfaceTypeExtensionNode
interface InterfaceTypeExtensionNode {}
property directives
readonly directives?: ReadonlyArray<ConstDirectiveNode>;
property fields
readonly fields?: ReadonlyArray<FieldDefinitionNode>;
property interfaces
readonly interfaces?: ReadonlyArray<NamedTypeNode>;
property kind
readonly kind: Kind.INTERFACE_TYPE_EXTENSION;
property loc
readonly loc?: Location;
property name
readonly name: NameNode;
interface IntrospectionDirective
interface IntrospectionDirective {}
property args
readonly args: ReadonlyArray<IntrospectionInputValue>;
property description
readonly description?: Maybe<string>;
property isRepeatable
readonly isRepeatable?: boolean;
property locations
readonly locations: ReadonlyArray<DirectiveLocation>;
property name
readonly name: string;
interface IntrospectionEnumType
interface IntrospectionEnumType {}
property description
readonly description?: Maybe<string>;
property enumValues
readonly enumValues: ReadonlyArray<IntrospectionEnumValue>;
property kind
readonly kind: 'ENUM';
property name
readonly name: string;
interface IntrospectionEnumValue
interface IntrospectionEnumValue {}
property deprecationReason
readonly deprecationReason: Maybe<string>;
property description
readonly description?: Maybe<string>;
property isDeprecated
readonly isDeprecated: boolean;
property name
readonly name: string;
interface IntrospectionField
interface IntrospectionField {}
property args
readonly args: ReadonlyArray<IntrospectionInputValue>;
property deprecationReason
readonly deprecationReason: Maybe<string>;
property description
readonly description?: Maybe<string>;
property isDeprecated
readonly isDeprecated: boolean;
property name
readonly name: string;
property type
readonly type: IntrospectionOutputTypeRef;
interface IntrospectionInputObjectType
interface IntrospectionInputObjectType {}
property description
readonly description?: Maybe<string>;
property inputFields
readonly inputFields: ReadonlyArray<IntrospectionInputValue>;
property isOneOf
readonly isOneOf: boolean;
property kind
readonly kind: 'INPUT_OBJECT';
property name
readonly name: string;
interface IntrospectionInputValue
interface IntrospectionInputValue {}
property defaultValue
readonly defaultValue: Maybe<string>;
property deprecationReason
readonly deprecationReason?: Maybe<string>;
property description
readonly description?: Maybe<string>;
property isDeprecated
readonly isDeprecated?: boolean;
property name
readonly name: string;
property type
readonly type: IntrospectionInputTypeRef;
interface IntrospectionInterfaceType
interface IntrospectionInterfaceType {}
property description
readonly description?: Maybe<string>;
property fields
readonly fields: ReadonlyArray<IntrospectionField>;
property interfaces
readonly interfaces: ReadonlyArray< IntrospectionNamedTypeRef<IntrospectionInterfaceType>>;
property kind
readonly kind: 'INTERFACE';
property name
readonly name: string;
property possibleTypes
readonly possibleTypes: ReadonlyArray< IntrospectionNamedTypeRef<IntrospectionObjectType>>;
interface IntrospectionListTypeRef
interface IntrospectionListTypeRef< T extends IntrospectionTypeRef = IntrospectionTypeRef> {}
interface IntrospectionNamedTypeRef
interface IntrospectionNamedTypeRef< T extends IntrospectionType = IntrospectionType> {}
interface IntrospectionNonNullTypeRef
interface IntrospectionNonNullTypeRef< T extends IntrospectionTypeRef = IntrospectionTypeRef> {}
interface IntrospectionObjectType
interface IntrospectionObjectType {}
property description
readonly description?: Maybe<string>;
property fields
readonly fields: ReadonlyArray<IntrospectionField>;
property interfaces
readonly interfaces: ReadonlyArray< IntrospectionNamedTypeRef<IntrospectionInterfaceType>>;
property kind
readonly kind: 'OBJECT';
property name
readonly name: string;
interface IntrospectionOptions
interface IntrospectionOptions {}
property descriptions
descriptions?: boolean;
Whether to include descriptions in the introspection result. Default: true
property directiveIsRepeatable
directiveIsRepeatable?: boolean;
Whether to include
isRepeatable
flag on directives. Default: false
property inputValueDeprecation
inputValueDeprecation?: boolean;
Whether target GraphQL server support deprecation of input values. Default: false
property oneOf
oneOf?: boolean;
Whether target GraphQL server supports
@oneOf
input objects. Default: false
property schemaDescription
schemaDescription?: boolean;
Whether to include
description
field on schema. Default: false
property specifiedByUrl
specifiedByUrl?: boolean;
Whether to include
specifiedByURL
in the introspection result. Default: false
interface IntrospectionQuery
interface IntrospectionQuery {}
interface IntrospectionScalarType
interface IntrospectionScalarType {}
property description
readonly description?: Maybe<string>;
property kind
readonly kind: 'SCALAR';
property name
readonly name: string;
property specifiedByURL
readonly specifiedByURL?: Maybe<string>;
interface IntrospectionSchema
interface IntrospectionSchema {}
property description
readonly description?: Maybe<string>;
property directives
readonly directives: ReadonlyArray<IntrospectionDirective>;
property mutationType
readonly mutationType: Maybe<IntrospectionNamedTypeRef<IntrospectionObjectType>>;
property queryType
readonly queryType: IntrospectionNamedTypeRef<IntrospectionObjectType>;
property subscriptionType
readonly subscriptionType: Maybe< IntrospectionNamedTypeRef<IntrospectionObjectType>>;
property types
readonly types: ReadonlyArray<IntrospectionType>;
interface IntrospectionUnionType
interface IntrospectionUnionType {}
property description
readonly description?: Maybe<string>;
property kind
readonly kind: 'UNION';
property name
readonly name: string;
property possibleTypes
readonly possibleTypes: ReadonlyArray< IntrospectionNamedTypeRef<IntrospectionObjectType>>;
interface IntValueNode
interface IntValueNode {}
interface ListTypeNode
interface ListTypeNode {}
interface ListValueNode
interface ListValueNode {}
interface NamedTypeNode
interface NamedTypeNode {}
interface NameNode
interface NameNode {}
Name
interface NonNullTypeNode
interface NonNullTypeNode {}
interface NullValueNode
interface NullValueNode {}
interface ObjectFieldNode
interface ObjectFieldNode {}
interface ObjectTypeDefinitionNode
interface ObjectTypeDefinitionNode {}
property description
readonly description?: StringValueNode;
property directives
readonly directives?: ReadonlyArray<ConstDirectiveNode>;
property fields
readonly fields?: ReadonlyArray<FieldDefinitionNode>;
property interfaces
readonly interfaces?: ReadonlyArray<NamedTypeNode>;
property kind
readonly kind: Kind.OBJECT_TYPE_DEFINITION;
property loc
readonly loc?: Location;
property name
readonly name: NameNode;
interface ObjectTypeExtensionNode
interface ObjectTypeExtensionNode {}
property directives
readonly directives?: ReadonlyArray<ConstDirectiveNode>;
property fields
readonly fields?: ReadonlyArray<FieldDefinitionNode>;
property interfaces
readonly interfaces?: ReadonlyArray<NamedTypeNode>;
property kind
readonly kind: Kind.OBJECT_TYPE_EXTENSION;
property loc
readonly loc?: Location;
property name
readonly name: NameNode;
interface ObjectValueNode
interface ObjectValueNode {}
interface OperationDefinitionNode
interface OperationDefinitionNode {}
property directives
readonly directives?: ReadonlyArray<DirectiveNode>;
property kind
readonly kind: Kind.OPERATION_DEFINITION;
property loc
readonly loc?: Location;
property name
readonly name?: NameNode;
property operation
readonly operation: OperationTypeNode;
property selectionSet
readonly selectionSet: SelectionSetNode;
property variableDefinitions
readonly variableDefinitions?: ReadonlyArray<VariableDefinitionNode>;
interface OperationTypeDefinitionNode
interface OperationTypeDefinitionNode {}
interface ParseOptions
interface ParseOptions {}
Configuration options to control parser behavior
property allowLegacyFragmentVariables
allowLegacyFragmentVariables?: boolean;
Deprecated
will be removed in the v17.0.0
If enabled, the parser will understand and parse variable definitions contained in a fragment definition. They'll be represented in the
variableDefinitions
field of the FragmentDefinitionNode.The syntax is identical to normal, query-defined variables. For example:
fragment A($var: Boolean = false) on T {...}
property maxTokens
maxTokens?: number | undefined;
Parser CPU and memory usage is linear to the number of tokens in a document however in extreme cases it becomes quadratic due to memory exhaustion. Parsing happens before validation so even invalid queries can burn lots of CPU time and memory. To prevent this you can set a maximum number of tokens allowed within a document.
property noLocation
noLocation?: boolean;
By default, the parser creates AST nodes that know the location in the source that they correspond to. This configuration flag disables that behavior for performance or testing.
interface ResponsePath
interface Path {}
interface ScalarTypeDefinitionNode
interface ScalarTypeDefinitionNode {}
property description
readonly description?: StringValueNode;
property directives
readonly directives?: ReadonlyArray<ConstDirectiveNode>;
property kind
readonly kind: Kind.SCALAR_TYPE_DEFINITION;
property loc
readonly loc?: Location;
property name
readonly name: NameNode;
interface ScalarTypeExtensionNode
interface ScalarTypeExtensionNode {}
property directives
readonly directives?: ReadonlyArray<ConstDirectiveNode>;
property kind
readonly kind: Kind.SCALAR_TYPE_EXTENSION;
property loc
readonly loc?: Location;
property name
readonly name: NameNode;
interface SchemaDefinitionNode
interface SchemaDefinitionNode {}
property description
readonly description?: StringValueNode;
property directives
readonly directives?: ReadonlyArray<ConstDirectiveNode>;
property kind
readonly kind: Kind.SCHEMA_DEFINITION;
property loc
readonly loc?: Location;
property operationTypes
readonly operationTypes: ReadonlyArray<OperationTypeDefinitionNode>;
interface SchemaExtensionNode
interface SchemaExtensionNode {}
property directives
readonly directives?: ReadonlyArray<ConstDirectiveNode>;
property kind
readonly kind: Kind.SCHEMA_EXTENSION;
property loc
readonly loc?: Location;
property operationTypes
readonly operationTypes?: ReadonlyArray<OperationTypeDefinitionNode>;
interface SelectionSetNode
interface SelectionSetNode {}
property kind
kind: Kind.SELECTION_SET;
property loc
loc?: Location;
property selections
selections: ReadonlyArray<SelectionNode>;
interface SourceLocation
interface SourceLocation {}
Represents a location in a Source.
interface StringValueNode
interface StringValueNode {}
interface SubscriptionArgs
interface SubscriptionArgs extends ExecutionArgs {}
Deprecated
use ExecutionArgs instead. Will be removed in v17
ExecutionArgs has been broadened to include all properties within SubscriptionArgs. The SubscriptionArgs type is retained for backwards compatibility.
interface TypedQueryDocumentNode
interface TypedQueryDocumentNode< TResponseData = { [key: string]: any; }, TRequestVariables = { [key: string]: any; }> extends DocumentNode {}
Wrapper type that contains DocumentNode and types that can be deduced from it.
property definitions
readonly definitions: ReadonlyArray<ExecutableDefinitionNode>;
interface UnionTypeDefinitionNode
interface UnionTypeDefinitionNode {}
property description
readonly description?: StringValueNode;
property directives
readonly directives?: ReadonlyArray<ConstDirectiveNode>;
property kind
readonly kind: Kind.UNION_TYPE_DEFINITION;
property loc
readonly loc?: Location;
property name
readonly name: NameNode;
property types
readonly types?: ReadonlyArray<NamedTypeNode>;
interface UnionTypeExtensionNode
interface UnionTypeExtensionNode {}
property directives
readonly directives?: ReadonlyArray<ConstDirectiveNode>;
property kind
readonly kind: Kind.UNION_TYPE_EXTENSION;
property loc
readonly loc?: Location;
property name
readonly name: NameNode;
property types
readonly types?: ReadonlyArray<NamedTypeNode>;
interface VariableDefinitionNode
interface VariableDefinitionNode {}
property defaultValue
readonly defaultValue?: ConstValueNode;
property directives
readonly directives?: ReadonlyArray<ConstDirectiveNode>;
property kind
readonly kind: Kind.VARIABLE_DEFINITION;
property loc
readonly loc?: Location;
property type
readonly type: TypeNode;
property variable
readonly variable: VariableNode;
interface VariableNode
interface VariableNode {}
Enums
enum BreakingChangeType
enum BreakingChangeType { TYPE_REMOVED = 'TYPE_REMOVED', TYPE_CHANGED_KIND = 'TYPE_CHANGED_KIND', TYPE_REMOVED_FROM_UNION = 'TYPE_REMOVED_FROM_UNION', VALUE_REMOVED_FROM_ENUM = 'VALUE_REMOVED_FROM_ENUM', REQUIRED_INPUT_FIELD_ADDED = 'REQUIRED_INPUT_FIELD_ADDED', IMPLEMENTED_INTERFACE_REMOVED = 'IMPLEMENTED_INTERFACE_REMOVED', FIELD_REMOVED = 'FIELD_REMOVED', FIELD_CHANGED_KIND = 'FIELD_CHANGED_KIND', REQUIRED_ARG_ADDED = 'REQUIRED_ARG_ADDED', ARG_REMOVED = 'ARG_REMOVED', ARG_CHANGED_KIND = 'ARG_CHANGED_KIND', DIRECTIVE_REMOVED = 'DIRECTIVE_REMOVED', DIRECTIVE_ARG_REMOVED = 'DIRECTIVE_ARG_REMOVED', REQUIRED_DIRECTIVE_ARG_ADDED = 'REQUIRED_DIRECTIVE_ARG_ADDED', DIRECTIVE_REPEATABLE_REMOVED = 'DIRECTIVE_REPEATABLE_REMOVED', DIRECTIVE_LOCATION_REMOVED = 'DIRECTIVE_LOCATION_REMOVED',}
member ARG_CHANGED_KIND
ARG_CHANGED_KIND = 'ARG_CHANGED_KIND'
member ARG_REMOVED
ARG_REMOVED = 'ARG_REMOVED'
member DIRECTIVE_ARG_REMOVED
DIRECTIVE_ARG_REMOVED = 'DIRECTIVE_ARG_REMOVED'
member DIRECTIVE_LOCATION_REMOVED
DIRECTIVE_LOCATION_REMOVED = 'DIRECTIVE_LOCATION_REMOVED'
member DIRECTIVE_REMOVED
DIRECTIVE_REMOVED = 'DIRECTIVE_REMOVED'
member DIRECTIVE_REPEATABLE_REMOVED
DIRECTIVE_REPEATABLE_REMOVED = 'DIRECTIVE_REPEATABLE_REMOVED'
member FIELD_CHANGED_KIND
FIELD_CHANGED_KIND = 'FIELD_CHANGED_KIND'
member FIELD_REMOVED
FIELD_REMOVED = 'FIELD_REMOVED'
member IMPLEMENTED_INTERFACE_REMOVED
IMPLEMENTED_INTERFACE_REMOVED = 'IMPLEMENTED_INTERFACE_REMOVED'
member REQUIRED_ARG_ADDED
REQUIRED_ARG_ADDED = 'REQUIRED_ARG_ADDED'
member REQUIRED_DIRECTIVE_ARG_ADDED
REQUIRED_DIRECTIVE_ARG_ADDED = 'REQUIRED_DIRECTIVE_ARG_ADDED'
member REQUIRED_INPUT_FIELD_ADDED
REQUIRED_INPUT_FIELD_ADDED = 'REQUIRED_INPUT_FIELD_ADDED'
member TYPE_CHANGED_KIND
TYPE_CHANGED_KIND = 'TYPE_CHANGED_KIND'
member TYPE_REMOVED
TYPE_REMOVED = 'TYPE_REMOVED'
member TYPE_REMOVED_FROM_UNION
TYPE_REMOVED_FROM_UNION = 'TYPE_REMOVED_FROM_UNION'
member VALUE_REMOVED_FROM_ENUM
VALUE_REMOVED_FROM_ENUM = 'VALUE_REMOVED_FROM_ENUM'
enum DangerousChangeType
enum DangerousChangeType { VALUE_ADDED_TO_ENUM = 'VALUE_ADDED_TO_ENUM', TYPE_ADDED_TO_UNION = 'TYPE_ADDED_TO_UNION', OPTIONAL_INPUT_FIELD_ADDED = 'OPTIONAL_INPUT_FIELD_ADDED', OPTIONAL_ARG_ADDED = 'OPTIONAL_ARG_ADDED', IMPLEMENTED_INTERFACE_ADDED = 'IMPLEMENTED_INTERFACE_ADDED', ARG_DEFAULT_VALUE_CHANGE = 'ARG_DEFAULT_VALUE_CHANGE',}
member ARG_DEFAULT_VALUE_CHANGE
ARG_DEFAULT_VALUE_CHANGE = 'ARG_DEFAULT_VALUE_CHANGE'
member IMPLEMENTED_INTERFACE_ADDED
IMPLEMENTED_INTERFACE_ADDED = 'IMPLEMENTED_INTERFACE_ADDED'
member OPTIONAL_ARG_ADDED
OPTIONAL_ARG_ADDED = 'OPTIONAL_ARG_ADDED'
member OPTIONAL_INPUT_FIELD_ADDED
OPTIONAL_INPUT_FIELD_ADDED = 'OPTIONAL_INPUT_FIELD_ADDED'
member TYPE_ADDED_TO_UNION
TYPE_ADDED_TO_UNION = 'TYPE_ADDED_TO_UNION'
member VALUE_ADDED_TO_ENUM
VALUE_ADDED_TO_ENUM = 'VALUE_ADDED_TO_ENUM'
enum DirectiveLocation
enum DirectiveLocation { QUERY = 'QUERY', MUTATION = 'MUTATION', SUBSCRIPTION = 'SUBSCRIPTION', FIELD = 'FIELD', FRAGMENT_DEFINITION = 'FRAGMENT_DEFINITION', FRAGMENT_SPREAD = 'FRAGMENT_SPREAD', INLINE_FRAGMENT = 'INLINE_FRAGMENT', VARIABLE_DEFINITION = 'VARIABLE_DEFINITION', SCHEMA = 'SCHEMA', SCALAR = 'SCALAR', OBJECT = 'OBJECT', FIELD_DEFINITION = 'FIELD_DEFINITION', ARGUMENT_DEFINITION = 'ARGUMENT_DEFINITION', INTERFACE = 'INTERFACE', UNION = 'UNION', ENUM = 'ENUM', ENUM_VALUE = 'ENUM_VALUE', INPUT_OBJECT = 'INPUT_OBJECT', INPUT_FIELD_DEFINITION = 'INPUT_FIELD_DEFINITION',}
The set of allowed directive location values.
member ARGUMENT_DEFINITION
ARGUMENT_DEFINITION = 'ARGUMENT_DEFINITION'
member ENUM
ENUM = 'ENUM'
member ENUM_VALUE
ENUM_VALUE = 'ENUM_VALUE'
member FIELD
FIELD = 'FIELD'
member FIELD_DEFINITION
FIELD_DEFINITION = 'FIELD_DEFINITION'
member FRAGMENT_DEFINITION
FRAGMENT_DEFINITION = 'FRAGMENT_DEFINITION'
member FRAGMENT_SPREAD
FRAGMENT_SPREAD = 'FRAGMENT_SPREAD'
member INLINE_FRAGMENT
INLINE_FRAGMENT = 'INLINE_FRAGMENT'
member INPUT_FIELD_DEFINITION
INPUT_FIELD_DEFINITION = 'INPUT_FIELD_DEFINITION'
member INPUT_OBJECT
INPUT_OBJECT = 'INPUT_OBJECT'
member INTERFACE
INTERFACE = 'INTERFACE'
member MUTATION
MUTATION = 'MUTATION'
member OBJECT
OBJECT = 'OBJECT'
member QUERY
QUERY = 'QUERY'
Request Definitions
member SCALAR
SCALAR = 'SCALAR'
member SCHEMA
SCHEMA = 'SCHEMA'
Type System Definitions
member SUBSCRIPTION
SUBSCRIPTION = 'SUBSCRIPTION'
member UNION
UNION = 'UNION'
member VARIABLE_DEFINITION
VARIABLE_DEFINITION = 'VARIABLE_DEFINITION'
enum Kind
enum Kind { NAME = 'Name', DOCUMENT = 'Document', OPERATION_DEFINITION = 'OperationDefinition', VARIABLE_DEFINITION = 'VariableDefinition', SELECTION_SET = 'SelectionSet', FIELD = 'Field', ARGUMENT = 'Argument', FRAGMENT_SPREAD = 'FragmentSpread', INLINE_FRAGMENT = 'InlineFragment', FRAGMENT_DEFINITION = 'FragmentDefinition', VARIABLE = 'Variable', INT = 'IntValue', FLOAT = 'FloatValue', STRING = 'StringValue', BOOLEAN = 'BooleanValue', NULL = 'NullValue', ENUM = 'EnumValue', LIST = 'ListValue', OBJECT = 'ObjectValue', OBJECT_FIELD = 'ObjectField', DIRECTIVE = 'Directive', NAMED_TYPE = 'NamedType', LIST_TYPE = 'ListType', NON_NULL_TYPE = 'NonNullType', SCHEMA_DEFINITION = 'SchemaDefinition', OPERATION_TYPE_DEFINITION = 'OperationTypeDefinition', SCALAR_TYPE_DEFINITION = 'ScalarTypeDefinition', OBJECT_TYPE_DEFINITION = 'ObjectTypeDefinition', FIELD_DEFINITION = 'FieldDefinition', INPUT_VALUE_DEFINITION = 'InputValueDefinition', INTERFACE_TYPE_DEFINITION = 'InterfaceTypeDefinition', UNION_TYPE_DEFINITION = 'UnionTypeDefinition', ENUM_TYPE_DEFINITION = 'EnumTypeDefinition', ENUM_VALUE_DEFINITION = 'EnumValueDefinition', INPUT_OBJECT_TYPE_DEFINITION = 'InputObjectTypeDefinition', DIRECTIVE_DEFINITION = 'DirectiveDefinition', SCHEMA_EXTENSION = 'SchemaExtension', SCALAR_TYPE_EXTENSION = 'ScalarTypeExtension', OBJECT_TYPE_EXTENSION = 'ObjectTypeExtension', INTERFACE_TYPE_EXTENSION = 'InterfaceTypeExtension', UNION_TYPE_EXTENSION = 'UnionTypeExtension', ENUM_TYPE_EXTENSION = 'EnumTypeExtension', INPUT_OBJECT_TYPE_EXTENSION = 'InputObjectTypeExtension',}
The set of allowed kind values for AST nodes.
member ARGUMENT
ARGUMENT = 'Argument'
member BOOLEAN
BOOLEAN = 'BooleanValue'
member DIRECTIVE
DIRECTIVE = 'Directive'
Directives
member DIRECTIVE_DEFINITION
DIRECTIVE_DEFINITION = 'DirectiveDefinition'
Directive Definitions
member DOCUMENT
DOCUMENT = 'Document'
Document
member ENUM
ENUM = 'EnumValue'
member ENUM_TYPE_DEFINITION
ENUM_TYPE_DEFINITION = 'EnumTypeDefinition'
member ENUM_TYPE_EXTENSION
ENUM_TYPE_EXTENSION = 'EnumTypeExtension'
member ENUM_VALUE_DEFINITION
ENUM_VALUE_DEFINITION = 'EnumValueDefinition'
member FIELD
FIELD = 'Field'
member FIELD_DEFINITION
FIELD_DEFINITION = 'FieldDefinition'
member FLOAT
FLOAT = 'FloatValue'
member FRAGMENT_DEFINITION
FRAGMENT_DEFINITION = 'FragmentDefinition'
member FRAGMENT_SPREAD
FRAGMENT_SPREAD = 'FragmentSpread'
Fragments
member INLINE_FRAGMENT
INLINE_FRAGMENT = 'InlineFragment'
member INPUT_OBJECT_TYPE_DEFINITION
INPUT_OBJECT_TYPE_DEFINITION = 'InputObjectTypeDefinition'
member INPUT_OBJECT_TYPE_EXTENSION
INPUT_OBJECT_TYPE_EXTENSION = 'InputObjectTypeExtension'
member INPUT_VALUE_DEFINITION
INPUT_VALUE_DEFINITION = 'InputValueDefinition'
member INT
INT = 'IntValue'
member INTERFACE_TYPE_DEFINITION
INTERFACE_TYPE_DEFINITION = 'InterfaceTypeDefinition'
member INTERFACE_TYPE_EXTENSION
INTERFACE_TYPE_EXTENSION = 'InterfaceTypeExtension'
member LIST
LIST = 'ListValue'
member LIST_TYPE
LIST_TYPE = 'ListType'
member NAME
NAME = 'Name'
Name
member NAMED_TYPE
NAMED_TYPE = 'NamedType'
Types
member NON_NULL_TYPE
NON_NULL_TYPE = 'NonNullType'
member NULL
NULL = 'NullValue'
member OBJECT
OBJECT = 'ObjectValue'
member OBJECT_FIELD
OBJECT_FIELD = 'ObjectField'
member OBJECT_TYPE_DEFINITION
OBJECT_TYPE_DEFINITION = 'ObjectTypeDefinition'
member OBJECT_TYPE_EXTENSION
OBJECT_TYPE_EXTENSION = 'ObjectTypeExtension'
member OPERATION_DEFINITION
OPERATION_DEFINITION = 'OperationDefinition'
member OPERATION_TYPE_DEFINITION
OPERATION_TYPE_DEFINITION = 'OperationTypeDefinition'
member SCALAR_TYPE_DEFINITION
SCALAR_TYPE_DEFINITION = 'ScalarTypeDefinition'
Type Definitions
member SCALAR_TYPE_EXTENSION
SCALAR_TYPE_EXTENSION = 'ScalarTypeExtension'
Type Extensions
member SCHEMA_DEFINITION
SCHEMA_DEFINITION = 'SchemaDefinition'
Type System Definitions
member SCHEMA_EXTENSION
SCHEMA_EXTENSION = 'SchemaExtension'
Type System Extensions
member SELECTION_SET
SELECTION_SET = 'SelectionSet'
member STRING
STRING = 'StringValue'
member UNION_TYPE_DEFINITION
UNION_TYPE_DEFINITION = 'UnionTypeDefinition'
member UNION_TYPE_EXTENSION
UNION_TYPE_EXTENSION = 'UnionTypeExtension'
member VARIABLE
VARIABLE = 'Variable'
Values
member VARIABLE_DEFINITION
VARIABLE_DEFINITION = 'VariableDefinition'
enum OperationTypeNode
enum OperationTypeNode { QUERY = 'query', MUTATION = 'mutation', SUBSCRIPTION = 'subscription',}
member MUTATION
MUTATION = 'mutation'
member QUERY
QUERY = 'query'
member SUBSCRIPTION
SUBSCRIPTION = 'subscription'
enum TokenKind
enum TokenKind { SOF = '<SOF>', EOF = '<EOF>', BANG = '!', DOLLAR = '$', AMP = '&', PAREN_L = '(', PAREN_R = ')', SPREAD = '...', COLON = ':', EQUALS = '=', AT = '@', BRACKET_L = '[', BRACKET_R = ']', BRACE_L = '{', PIPE = '|', BRACE_R = '}', NAME = 'Name', INT = 'Int', FLOAT = 'Float', STRING = 'String', BLOCK_STRING = 'BlockString', COMMENT = 'Comment',}
An exported enum describing the different kinds of tokens that the lexer emits.
member AMP
AMP = '&'
member AT
AT = '@'
member BANG
BANG = '!'
member BLOCK_STRING
BLOCK_STRING = 'BlockString'
member BRACE_L
BRACE_L = '{'
member BRACE_R
BRACE_R = '}'
member BRACKET_L
BRACKET_L = '['
member BRACKET_R
BRACKET_R = ']'
member COLON
COLON = ':'
member COMMENT
COMMENT = 'Comment'
member DOLLAR
DOLLAR = '$'
member EOF
EOF = '<EOF>'
member EQUALS
EQUALS = '='
member FLOAT
FLOAT = 'Float'
member INT
INT = 'Int'
member NAME
NAME = 'Name'
member PAREN_L
PAREN_L = '('
member PAREN_R
PAREN_R = ')'
member PIPE
PIPE = '|'
member SOF
SOF = '<SOF>'
member SPREAD
SPREAD = '...'
member STRING
STRING = 'String'
enum TypeKind
enum TypeKind { SCALAR = 'SCALAR', OBJECT = 'OBJECT', INTERFACE = 'INTERFACE', UNION = 'UNION', ENUM = 'ENUM', INPUT_OBJECT = 'INPUT_OBJECT', LIST = 'LIST', NON_NULL = 'NON_NULL',}
Type Aliases
type ASTKindToNode
type ASTKindToNode = { [NodeT in ASTNode as NodeT['kind']]: NodeT;};
Utility type listing all nodes indexed by their kind.
type ASTNode
type ASTNode = | NameNode | DocumentNode | OperationDefinitionNode | VariableDefinitionNode | VariableNode | SelectionSetNode | FieldNode | ArgumentNode | FragmentSpreadNode | InlineFragmentNode | FragmentDefinitionNode | IntValueNode | FloatValueNode | StringValueNode | BooleanValueNode | NullValueNode | EnumValueNode | ListValueNode | ObjectValueNode | ObjectFieldNode | DirectiveNode | NamedTypeNode | ListTypeNode | NonNullTypeNode | SchemaDefinitionNode | OperationTypeDefinitionNode | ScalarTypeDefinitionNode | ObjectTypeDefinitionNode | FieldDefinitionNode | InputValueDefinitionNode | InterfaceTypeDefinitionNode | UnionTypeDefinitionNode | EnumTypeDefinitionNode | EnumValueDefinitionNode | InputObjectTypeDefinitionNode | DirectiveDefinitionNode | SchemaExtensionNode | ScalarTypeExtensionNode | ObjectTypeExtensionNode | InterfaceTypeExtensionNode | UnionTypeExtensionNode | EnumTypeExtensionNode | InputObjectTypeExtensionNode;
The list of all possible AST node types.
type ASTVisitFn
type ASTVisitFn<TVisitedNode extends ASTNode> = ( /** The current node being visiting. */ node: TVisitedNode, /** The index or key to this node from the parent node or Array. */ key: string | number | undefined, /** The parent immediately above this node, which may be an Array. */ parent: ASTNode | ReadonlyArray<ASTNode> | undefined, /** The key path to get to this node from the root node. */ path: ReadonlyArray<string | number>, /** * All nodes and Arrays visited before reaching parent of this node. * These correspond to array indices in `path`. * Note: ancestors includes arrays which contain the parent of visited node. */ ancestors: ReadonlyArray<ASTNode | ReadonlyArray<ASTNode>>) => any;
A visitor is comprised of visit functions, which are called on each node during the visitor's traversal.
type ASTVisitor
type 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.
type ASTVisitorKeyMap
type 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
type ConstValueNode
type ConstValueNode = | IntValueNode | FloatValueNode | StringValueNode | BooleanValueNode | NullValueNode | EnumValueNode | ConstListValueNode | ConstObjectValueNode;
type DefinitionNode
type DefinitionNode = | ExecutableDefinitionNode | TypeSystemDefinitionNode | TypeSystemExtensionNode;
type DirectiveLocationEnum
type DirectiveLocationEnum = typeof DirectiveLocation;
The enum type representing the directive location values.
Deprecated
Please use
DirectiveLocation
. Will be remove in v17.
type ExecutableDefinitionNode
type ExecutableDefinitionNode = OperationDefinitionNode | FragmentDefinitionNode;
type GraphQLAbstractType
type GraphQLAbstractType = GraphQLInterfaceType | GraphQLUnionType;
These types may describe the parent context of a selection set.
type GraphQLCompositeType
type GraphQLCompositeType = | GraphQLObjectType | GraphQLInterfaceType | GraphQLUnionType;
These types may describe the parent context of a selection set.
type GraphQLEnumValueConfigMap
type GraphQLEnumValueConfigMap = ObjMap<GraphQLEnumValueConfig>;
type GraphQLFieldConfigArgumentMap
type GraphQLFieldConfigArgumentMap = ObjMap<GraphQLArgumentConfig>;
type GraphQLFieldConfigMap
type GraphQLFieldConfigMap<TSource, TContext> = ObjMap< GraphQLFieldConfig<TSource, TContext>>;
type GraphQLFieldMap
type GraphQLFieldMap<TSource, TContext> = ObjMap<GraphQLField<TSource, TContext>>;
type GraphQLFieldResolver
type GraphQLFieldResolver<TSource, TContext, TArgs = any, TResult = unknown> = ( source: TSource, args: TArgs, context: TContext, info: GraphQLResolveInfo) => TResult;
type GraphQLInputFieldConfigMap
type GraphQLInputFieldConfigMap = ObjMap<GraphQLInputFieldConfig>;
type GraphQLInputFieldMap
type GraphQLInputFieldMap = ObjMap<GraphQLInputField>;
type GraphQLInputType
type GraphQLInputType = | GraphQLScalarType | GraphQLEnumType | GraphQLInputObjectType | GraphQLList<GraphQLInputType> | GraphQLNonNull< | GraphQLScalarType | GraphQLEnumType | GraphQLInputObjectType | GraphQLList<GraphQLInputType> >;
These types may be used as input types for arguments and directives.
type GraphQLIsTypeOfFn
type GraphQLIsTypeOfFn<TSource, TContext> = ( source: TSource, context: TContext, info: GraphQLResolveInfo) => PromiseOrValue<boolean>;
type GraphQLLeafType
type GraphQLLeafType = GraphQLScalarType | GraphQLEnumType;
These types may describe types which may be leaf values.
type GraphQLNamedInputType
type GraphQLNamedInputType = | GraphQLScalarType | GraphQLEnumType | GraphQLInputObjectType;
type GraphQLNamedOutputType
type GraphQLNamedOutputType = | GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | GraphQLUnionType | GraphQLEnumType;
type GraphQLNamedType
type GraphQLNamedType = GraphQLNamedInputType | GraphQLNamedOutputType;
These named types do not include modifiers like List or NonNull.
type GraphQLNullableType
type GraphQLNullableType = | GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | GraphQLUnionType | GraphQLEnumType | GraphQLInputObjectType | GraphQLList<GraphQLType>;
These types can all accept null as a value.
type GraphQLOutputType
type GraphQLOutputType = | GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | GraphQLUnionType | GraphQLEnumType | GraphQLList<GraphQLOutputType> | GraphQLNonNull< | GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | GraphQLUnionType | GraphQLEnumType | GraphQLList<GraphQLOutputType> >;
These types may be used as output types as the result of fields.
type GraphQLScalarLiteralParser
type GraphQLScalarLiteralParser<TInternal> = ( valueNode: ValueNode, variables?: Maybe<ObjMap<unknown>>) => TInternal;
type GraphQLScalarSerializer
type GraphQLScalarSerializer<TExternal> = (outputValue: unknown) => TExternal;
type GraphQLScalarValueParser
type GraphQLScalarValueParser<TInternal> = (inputValue: unknown) => TInternal;
type GraphQLType
type GraphQLType = | GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | GraphQLUnionType | GraphQLEnumType | GraphQLInputObjectType | GraphQLList<GraphQLType> | GraphQLNonNull< | GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | GraphQLUnionType | GraphQLEnumType | GraphQLInputObjectType | GraphQLList<GraphQLType> >;
These are all of the possible kinds of types.
type GraphQLTypeResolver
type GraphQLTypeResolver<TSource, TContext> = ( value: TSource, context: TContext, info: GraphQLResolveInfo, abstractType: GraphQLAbstractType) => PromiseOrValue<string | undefined>;
type GraphQLWrappingType
type GraphQLWrappingType = GraphQLList<GraphQLType> | GraphQLNonNull<GraphQLType>;
These types wrap and modify other types
type IntrospectionInputType
type IntrospectionInputType = | IntrospectionScalarType | IntrospectionEnumType | IntrospectionInputObjectType;
type IntrospectionInputTypeRef
type IntrospectionInputTypeRef = | IntrospectionNamedTypeRef<IntrospectionInputType> | IntrospectionListTypeRef<IntrospectionInputTypeRef> | IntrospectionNonNullTypeRef< | IntrospectionNamedTypeRef<IntrospectionInputType> | IntrospectionListTypeRef<IntrospectionInputTypeRef> >;
type IntrospectionOutputType
type IntrospectionOutputType = | IntrospectionScalarType | IntrospectionObjectType | IntrospectionInterfaceType | IntrospectionUnionType | IntrospectionEnumType;
type IntrospectionOutputTypeRef
type IntrospectionOutputTypeRef = | IntrospectionNamedTypeRef<IntrospectionOutputType> | IntrospectionListTypeRef<IntrospectionOutputTypeRef> | IntrospectionNonNullTypeRef< | IntrospectionNamedTypeRef<IntrospectionOutputType> | IntrospectionListTypeRef<IntrospectionOutputTypeRef> >;
type IntrospectionType
type IntrospectionType = | IntrospectionScalarType | IntrospectionObjectType | IntrospectionInterfaceType | IntrospectionUnionType | IntrospectionEnumType | IntrospectionInputObjectType;
type IntrospectionTypeRef
type IntrospectionTypeRef = | IntrospectionNamedTypeRef | IntrospectionListTypeRef | IntrospectionNonNullTypeRef< IntrospectionNamedTypeRef | IntrospectionListTypeRef >;
type KindEnum
type KindEnum = typeof Kind;
The enum type representing the possible kind values of AST nodes.
Deprecated
Please use
Kind
. Will be remove in v17.
type SelectionNode
type SelectionNode = FieldNode | FragmentSpreadNode | InlineFragmentNode;
type ThunkObjMap
type ThunkObjMap<T> = (() => ObjMap<T>) | ObjMap<T>;
type ThunkReadonlyArray
type ThunkReadonlyArray<T> = (() => ReadonlyArray<T>) | ReadonlyArray<T>;
Used while defining GraphQL types to allow for circular references in otherwise immutable type definitions.
type TokenKindEnum
type TokenKindEnum = typeof TokenKind;
The enum type representing the token kinds values.
Deprecated
Please use
TokenKind
. Will be remove in v17.
type TypeDefinitionNode
type TypeDefinitionNode = | ScalarTypeDefinitionNode | ObjectTypeDefinitionNode | InterfaceTypeDefinitionNode | UnionTypeDefinitionNode | EnumTypeDefinitionNode | InputObjectTypeDefinitionNode;
Type Definition
type TypeExtensionNode
type TypeExtensionNode = | ScalarTypeExtensionNode | ObjectTypeExtensionNode | InterfaceTypeExtensionNode | UnionTypeExtensionNode | EnumTypeExtensionNode | InputObjectTypeExtensionNode;
Type Extensions
type TypeNode
type TypeNode = NamedTypeNode | ListTypeNode | NonNullTypeNode;
Type Reference
type TypeSystemDefinitionNode
type TypeSystemDefinitionNode = | SchemaDefinitionNode | TypeDefinitionNode | DirectiveDefinitionNode;
Type System Definition
type TypeSystemExtensionNode
type TypeSystemExtensionNode = SchemaExtensionNode | TypeExtensionNode;
Type System Extensions
type ValidationRule
type ValidationRule = (context: ValidationContext) => ASTVisitor;
type ValueNode
type ValueNode = | VariableNode | IntValueNode | FloatValueNode | StringValueNode | BooleanValueNode | NullValueNode | EnumValueNode | ListValueNode | ObjectValueNode;
Values
Package Files (92)
- error/GraphQLError.d.ts
- error/locatedError.d.ts
- error/syntaxError.d.ts
- execution/execute.d.ts
- execution/subscribe.d.ts
- execution/values.d.ts
- graphql.d.ts
- index.d.ts
- jsutils/Path.d.ts
- language/ast.d.ts
- language/directiveLocation.d.ts
- language/kinds.d.ts
- language/lexer.d.ts
- language/location.d.ts
- language/parser.d.ts
- language/predicates.d.ts
- language/printLocation.d.ts
- language/printer.d.ts
- language/source.d.ts
- language/tokenKind.d.ts
- language/visitor.d.ts
- subscription/index.d.ts
- type/assertName.d.ts
- type/definition.d.ts
- type/directives.d.ts
- type/introspection.d.ts
- type/scalars.d.ts
- type/schema.d.ts
- type/validate.d.ts
- utilities/TypeInfo.d.ts
- utilities/assertValidName.d.ts
- utilities/astFromValue.d.ts
- utilities/buildASTSchema.d.ts
- utilities/buildClientSchema.d.ts
- utilities/coerceInputValue.d.ts
- utilities/concatAST.d.ts
- utilities/extendSchema.d.ts
- utilities/findBreakingChanges.d.ts
- utilities/getIntrospectionQuery.d.ts
- utilities/getOperationAST.d.ts
- utilities/getOperationRootType.d.ts
- utilities/introspectionFromSchema.d.ts
- utilities/lexicographicSortSchema.d.ts
- utilities/printSchema.d.ts
- utilities/separateOperations.d.ts
- utilities/stripIgnoredCharacters.d.ts
- utilities/typeComparators.d.ts
- utilities/typeFromAST.d.ts
- utilities/typedQueryDocumentNode.d.ts
- utilities/valueFromAST.d.ts
- utilities/valueFromASTUntyped.d.ts
- validation/ValidationContext.d.ts
- validation/rules/ExecutableDefinitionsRule.d.ts
- validation/rules/FieldsOnCorrectTypeRule.d.ts
- validation/rules/FragmentsOnCompositeTypesRule.d.ts
- validation/rules/KnownArgumentNamesRule.d.ts
- validation/rules/KnownDirectivesRule.d.ts
- validation/rules/KnownFragmentNamesRule.d.ts
- validation/rules/KnownTypeNamesRule.d.ts
- validation/rules/LoneAnonymousOperationRule.d.ts
- validation/rules/LoneSchemaDefinitionRule.d.ts
- validation/rules/MaxIntrospectionDepthRule.d.ts
- validation/rules/NoFragmentCyclesRule.d.ts
- validation/rules/NoUndefinedVariablesRule.d.ts
- validation/rules/NoUnusedFragmentsRule.d.ts
- validation/rules/NoUnusedVariablesRule.d.ts
- validation/rules/OverlappingFieldsCanBeMergedRule.d.ts
- validation/rules/PossibleFragmentSpreadsRule.d.ts
- validation/rules/PossibleTypeExtensionsRule.d.ts
- validation/rules/ProvidedRequiredArgumentsRule.d.ts
- validation/rules/ScalarLeafsRule.d.ts
- validation/rules/SingleFieldSubscriptionsRule.d.ts
- validation/rules/UniqueArgumentDefinitionNamesRule.d.ts
- validation/rules/UniqueArgumentNamesRule.d.ts
- validation/rules/UniqueDirectiveNamesRule.d.ts
- validation/rules/UniqueDirectivesPerLocationRule.d.ts
- validation/rules/UniqueEnumValueNamesRule.d.ts
- validation/rules/UniqueFieldDefinitionNamesRule.d.ts
- validation/rules/UniqueFragmentNamesRule.d.ts
- validation/rules/UniqueInputFieldNamesRule.d.ts
- validation/rules/UniqueOperationNamesRule.d.ts
- validation/rules/UniqueOperationTypesRule.d.ts
- validation/rules/UniqueTypeNamesRule.d.ts
- validation/rules/UniqueVariableNamesRule.d.ts
- validation/rules/ValuesOfCorrectTypeRule.d.ts
- validation/rules/VariablesAreInputTypesRule.d.ts
- validation/rules/VariablesInAllowedPositionRule.d.ts
- validation/rules/custom/NoDeprecatedCustomRule.d.ts
- validation/rules/custom/NoSchemaIntrospectionCustomRule.d.ts
- validation/specifiedRules.d.ts
- validation/validate.d.ts
- version.d.ts
Dependencies (0)
No dependencies.
Dev Dependencies (0)
No dev dependencies.
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/graphql
.
- Markdown[![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/graphql)
- HTML<a href="https://www.jsdocs.io/package/graphql"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 12627 ms. - Missing or incorrect documentation? Open an issue for this package.