Skip to main content
Latest
class GraphQLUnionType
import { GraphQLUnionType } from "https://deno.land/x/kilatgraphql@16.6.0-1/mod.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

private
_types
astNode: Maybe<UnionTypeDefinitionNode>
description: Maybe<string>
extensionASTNodes: ReadonlyArray<UnionTypeExtensionNode>
extensions: Readonly<GraphQLUnionTypeExtensions>
name: string
resolveType: Maybe<GraphQLTypeResolver<any, any>>
readonly
[Symbol.toStringTag]: string

Methods

getTypes(): ReadonlyArray<GraphQLObjectType>
toConfig(): GraphQLUnionTypeNormalizedConfig
toJSON(): string
toString(): string