Skip to main content

guard

Custom GraphQL type guards and property guards.

executableDirectiveLocation()

function executableDirectiveLocation(directive): boolean

Defined in: packages/graphql/src/guard.ts:104

Checks if a directive is executable (related to operations).

Parameters

directive

GraphQLDirective

Returns

boolean


instanceOf()

function instanceOf<T>(obj, type): obj is () => T

Defined in: packages/graphql/src/guard.ts:58

Checks if a GraphQL named type is of generic type T.

Type Parameters

T

a GraphQL type to check against, eg GraphQLObjectType.

Parameters

obj

unknown

a GraphQL named type from the GraphQL schema.

type

() => T

the GraphQL type T.

Returns

obj is () => T


isApiType()

function isApiType(type): boolean

Defined in: packages/graphql/src/guard.ts:140

Checks if a type belongs to API (operation related).

Parameters

type

unknown

a GraphQL type.

Returns

boolean


isDeprecated()

function isDeprecated<T>(obj): obj is DeprecatedType<T>

Defined in: packages/graphql/src/guard.ts:79

Checks if a GraphQL named type is deprecated.

Type Parameters

T

a GraphQL type to check against, eg GraphQLObjectType.

Parameters

obj

T

an instance of T.

Returns

obj is DeprecatedType<T>


isGraphQLFieldType()

function isGraphQLFieldType(type): type is GraphQLField<unknown, unknown, unknown>

Defined in: packages/graphql/src/guard.ts:39

Checks if a GraphQL named type is of type GraphQLField.

Parameters

type

unknown

a GraphQL type.

Returns

type is GraphQLField<unknown, unknown, unknown>


isOperation()

function isOperation(type): type is GraphQLOperationType

Defined in: packages/graphql/src/guard.ts:94

Checks if a GraphQL type a GraphQL operation (query, mutation, subscription).

Parameters

type

unknown

a GraphQL type.

Returns

type is GraphQLOperationType


isSystemType()

function isSystemType(type): boolean

Defined in: packages/graphql/src/guard.ts:153

Checks if a type belongs to schema (schema type definition excluding operations related types).

Parameters

type

unknown

a GraphQL type.

Returns

boolean


typeSystemDirectiveLocation()

function typeSystemDirectiveLocation(directive): boolean

Defined in: packages/graphql/src/guard.ts:127

Checks if a directive is system (related to schema definition).

Parameters

directive

GraphQLDirective

Returns

boolean