Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

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;
    }
  }
});
class GraphQLUnionType {
constructor(config: Readonly<GraphQLUnionTypeConfig<any, any>>);
private _types;
astNode: Maybe<UnionTypeDefinitionNode>;
description: Maybe<string>;
extensionASTNodes: ReadonlyArray<UnionTypeExtensionNode>;
extensions: Readonly<GraphQLUnionTypeExtensions>;
name: string;
resolveType: Maybe<GraphQLTypeResolver<any, any>>;
get [Symbol.toStringTag](): string;
 
getTypes(): ReadonlyArray<GraphQLObjectType>;
toConfig(): GraphQLUnionTypeNormalizedConfig;
toJSON(): string;
toString(): string;
}

§Constructors

§
new GraphQLUnionType(config: Readonly<GraphQLUnionTypeConfig<any, any>>)
[src]

§Properties

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

§Methods

§
getTypes(): ReadonlyArray<GraphQLObjectType>
[src]
§
toConfig(): GraphQLUnionTypeNormalizedConfig
[src]
§
toJSON(): string
[src]
§
toString(): string
[src]