UnionTypeComposer
Class that helps to create UnionTypeComposer
s and provide ability to modify them.
Static methods
static create()
Create UnionTypeComposer
with adding it by name to the SchemaComposer
.
static create<TSrc = any, TCtx = any>(
typeDef:
| TypeAsString
| ComposeUnionTypeConfig<any, TContext>,
): UnionTypeComposer<TSrc, TCtx>
static createTemp()
Create UnionTypeComposer
without adding it to the SchemaComposer
. This method may be usefull in plugins, when you need to create type temporary.
static createTemp<TCtx>(
opts:
| TypeAsString
| ComposeUnionTypeConfig<any, TContext>,
): UnionTypeComposer<TSrc, TCtx>
Properties
schemaComposer
Current SchemaComposer
instance which is used for storing types created by UnionTypeComposer
.
SomeUTC.schemaComposer: SchemaComposer
Union Types methods
hasType()
hasType(
name: string | GraphQLObjectType | TypeComposer<TContext>
): boolean
getTypes()
getTypes(): ComposeTypesArray
getTypeNames()
getTypeNames(): string[]
setTypes()
setTypes(
types: ComposeTypesArray
): this
addType()
addType(
type: ComposeObjectType
): this
removeType()
removeType(
nameOrArray: string | string[]
): this
removeOtherTypes()
removeOtherTypes(
nameOrArray: string | string[]
): this
Type methods
getType()
getType(): GraphQLUnionType
getTypePlural()
getTypePlural(): GraphQLList<GraphQLUnionType>
getTypeNonNull()
getTypeNonNull(): GraphQLNonNull<GraphQLUnionType>
getTypeName()
getTypeName(): string
setTypeName()
setTypeName(
name: string
): this
getDescription()
getDescription(): string
setDescription()
setDescription(
description: string
): this
clone()
clone(
newTypeName: string
): this
ResolveType methods
getResolveType()
getResolveType(): GraphQLTypeResolver<any, TContext> | null | void
setResolveType()
setResolveType(
fn: GraphQLTypeResolver<any, TContext> | null | void,
): this
hasTypeResolver()
hasTypeResolver(
type: TypeComposer<any, TContext> | GraphQLObjectType,
): boolean
getTypeResolvers()
getTypeResolvers(): UnionTypeResolversMap<TSource, TContext>
getTypeResolverCheckFn()
getTypeResolverCheckFn(
type: TypeComposer<any, TContext> | GraphQLObjectType,
): UnionTypeResolverCheckFn<any, TContext>
getTypeResolverNames()
getTypeResolverNames(): string[]
getTypeResolverTypes()
getTypeResolverTypes(): GraphQLObjectType[]
setTypeResolvers()
setTypeResolvers(
typeResolversMap: UnionTypeResolversMap<any, TContext>,
): this
addTypeResolver()
addTypeResolver(
type: TypeComposer<any, TContext> | GraphQLObjectType,
checkFn: UnionTypeResolverCheckFn<any, TContext>,
): this
removeTypeResolver()
removeTypeResolver(
type: TypeComposer<any, TContext> | GraphQLObjectType,
): this
Internal type definitions
Flowtype definitions which are used in this class.
type UnionTypeComposerDefinition<TContext> =
| TypeAsString
| ComposeUnionTypeConfig<any, TContext>;
GraphQLUnionTypeExtended<TSource, TContext>
type GraphQLUnionTypeExtended<TSource, TContext> = GraphQLUnionType & {
_gqcTypeMap: Map<string, ComposeObjectType>;
_gqcTypeResolvers?: UnionTypeResolversMap<TSource, TContext>;
};
ComposeTypesArray
type ComposeTypesArray = ComposeObjectType[];
UnionTypeResolversMap<TSource, TContext>
type UnionTypeResolversMap<TSource, TContext> = Map<
ComposeObjectType,
UnionTypeResolverCheckFn<TSource, TContext>
>;
type MaybePromise<T> = Promise<T> | T;
UnionTypeResolverCheckFn<TSource, TContext>
type UnionTypeResolverCheckFn<TSource, TContext> = (
value: TSource,
context: TContext,
info: GraphQLResolveInfo,
) => MaybePromise<boolean | null | undefined>;
ComposeUnionTypeConfig<TSource, TContext>
type ComposeUnionTypeConfig<TSource, TContext> = {
name: string;
types?: Thunk<ComposeTypesArray>;
resolveType?: GraphQLTypeResolver<TSource, TContext> | null;
description?: string | null;
};