Latest
class GraphQLUnionType
import { GraphQLUnionType } from "https://dotland.deno.dev/x/graphql_deno@v15.0.0/lib/type/index.d.ts";

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

Constructors

new
GraphQLUnionType(config: Readonly<GraphQLUnionTypeConfig<any, any>>)

Properties

astNode: Maybe<UnionTypeDefinitionNode>
description: Maybe<string>
extensionASTNodes: Maybe<ReadonlyArray<UnionTypeExtensionNode>>
extensions: Maybe<Readonly<Record<string, any>>>
name: string
resolveType: Maybe<GraphQLTypeResolver<any, any>>

Methods

inspect(): string
toConfig(): GraphQLUnionTypeConfig<any, any> & { types: Array<GraphQLObjectType>; extensions: Maybe<Readonly<Record<string, any>>>; extensionASTNodes: ReadonlyArray<UnionTypeExtensionNode>; }
toJSON(): string
toString(): string