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
§
astNode: Maybe<UnionTypeDefinitionNode>
[src]§
extensionASTNodes: ReadonlyArray<UnionTypeExtensionNode>
[src]§
extensions: Readonly<GraphQLUnionTypeExtensions>
[src]§
resolveType: Maybe<GraphQLTypeResolver<any, any>>
[src]§Methods
§
getTypes(): ReadonlyArray<GraphQLObjectType>
[src]