v16 APIgraphql/utilitiesSchema Coordinates

graphql/utilities/schema-coordinates

Functions

resolveSchemaCoordinate()

A schema coordinate is resolved in the context of a GraphQL schema to uniquely identify a schema element. It returns undefined if the schema coordinate does not resolve to a schema element, meta-field, or introspection schema element. It will throw if the containing schema element (if applicable) does not exist.

https://spec.graphql.org/draft/#sec-Schema-Coordinates.Semantics

Signature:

resolveSchemaCoordinate(schema: GraphQLSchema, schemaCoordinate: string | Source): ResolvedSchemaElement | undefined

Arguments

NameTypeDescription
schemaGraphQLSchemaThe GraphQL schema to use.
schemaCoordinatestring | SourceThe schema coordinate to resolve.

Returns

TypeDescription
ResolvedSchemaElement | undefinedThe schema element identified by the coordinate, or undefined if none exists.

Example

import { resolveSchemaCoordinate } from 'graphql/utilities';
 
const result = resolveSchemaCoordinate(schema, schemaCoordinate);
 
// result contains the resolveSchemaCoordinate return value

resolveASTSchemaCoordinate()

Resolves schema coordinate from a parsed SchemaCoordinate node.

Signature:

resolveASTSchemaCoordinate(schema: GraphQLSchema, schemaCoordinate: SchemaCoordinateNode): ResolvedSchemaElement | undefined

Arguments

NameTypeDescription
schemaGraphQLSchemaThe GraphQL schema to use.
schemaCoordinateSchemaCoordinateNodeThe schema coordinate to resolve.

Returns

TypeDescription
ResolvedSchemaElement | undefinedThe schema element identified by the parsed coordinate, or undefined if none exists.

Example

import { resolveASTSchemaCoordinate } from 'graphql/utilities';
 
const result = resolveASTSchemaCoordinate(schema, schemaCoordinate);
 
// result contains the resolveASTSchemaCoordinate return value

Types

ResolvedSchemaElement

Type alias. A schema element resolved from a schema coordinate.

type ResolvedSchemaElement = { kind: ‘NamedType’; type: GraphQLNamedType } | { kind: ‘Field’; type: GraphQLObjectType | GraphQLInterfaceType; field: GraphQLField<unknown, unknown> } | { kind: ‘InputField’; type: GraphQLInputObjectType; inputField: GraphQLInputField } | { kind: ‘EnumValue’; type: GraphQLEnumType; enumValue: GraphQLEnumValue } | { kind: ‘FieldArgument’; type: GraphQLObjectType | GraphQLInterfaceType; field: GraphQLField<unknown, unknown>; fieldArgument: GraphQLArgument } | { kind: ‘Directive’; directive: GraphQLDirective } | { kind: ‘DirectiveArgument’; directive: GraphQLDirective; directiveArgument: GraphQLArgument };