Skip to main content

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;
}
}
});

Implements

  • GraphQLSchemaElement

Index

Constructors

constructor

Properties

astNode

astNode: Maybe<UnionTypeDefinitionNode>

description

description: Maybe<string>

extensionASTNodes

extensionASTNodes: readonly UnionTypeExtensionNode[]

extensions

extensions: Readonly<GraphQLUnionTypeExtensions>

name

name: string

resolveType

resolveType: Maybe<GraphQLTypeResolver<any, any>>

Accessors

[toStringTag]

  • get [toStringTag](): string
  • Returns string

Methods

getTypes

toConfig

  • toConfig(): GraphQLUnionTypeNormalizedConfig
  • Returns GraphQLUnionTypeNormalizedConfig

toJSON

  • toJSON(): string
  • Returns string

toString

  • toString(): string
  • Returns string