Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/drash/src/services/graphql/graphql.ts>GraphQL.GraphQLUnionType

A microframework for Deno's HTTP server with zero third-party dependencies
Go to Latest
class GraphQL.GraphQLUnionType
import { GraphQL } from "https://deno.land/x/drash@v2.8.1/src/services/graphql/graphql.ts";
const { GraphQLUnionType } = GraphQL;

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<GraphQLUnionTypeExtensions>>
name: string
resolveType: Maybe<GraphQLTypeResolver<any, any>>

Methods

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