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>
extensionASTNodes: Maybe<ReadonlyArray<UnionTypeExtensionNode>>
extensions: Maybe<Readonly<GraphQLUnionTypeExtensions>>
resolveType: Maybe<GraphQLTypeResolver<any, any>>
Methods
getTypes(): Array<GraphQLObjectType>
inspect(): string
toConfig(): GraphQLUnionTypeConfig<any, any> & { types: Array<GraphQLObjectType>; extensions: Maybe<Readonly<GraphQLUnionTypeExtensions>>; extensionASTNodes: ReadonlyArray<UnionTypeExtensionNode>; }
toJSON(): string
toString(): string