UnionTypeComposer
Class that helps to create UnionTypeComposer
s and provide ability to modify them.
Static methods
static create()
static create<TSrc = any, TCtx = any>(
typeDef: UnionTypeComposeDefinition<TSrc, TCtx>,
schemaComposer: SchemaComposer<TCtx>
): UnionTypeComposer<TSrc, TCtx>
Create UnionTypeComposer
with adding it by name to the SchemaComposer
.
static createTemp()
static createTemp<TSrc = any, TCtx = any>(
typeDef: UnionTypeComposeDefinition<TSrc, TCtx>,
schemaComposer: SchemaComposer<TCtx>
): UnionTypeComposer<TSrc, TCtx>
Create UnionTypeComposer
without adding it to the SchemaComposer
. This method may be usefull in plugins, when you need to create type temporary.
Properties
schemaComposer
schemaComposer: SchemaComposer<TContext>;
Union Types methods
hasType()
hasType(
name: string | GraphQLObjectType | ObjectTypeComposer<any, TContext>
): boolean
getTypes()
getTypes(): ComposeObjectType[]
getTypeNames()
getTypeNames(): string[]
clearTypes()
clearTypes(): UnionTypeComposer<TSource, TContext>
setTypes()
setTypes(
types: ComposeObjectType[]
): 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
): UnionTypeComposer<TSource, TContext>
ResolveType methods
getResolveType()
getResolveType(): GraphQLTypeResolver<TSource, TContext> | null | void
setResolveType()
setResolveType(
fn: GraphQLTypeResolver<TSource, TContext> | null | void
): this
hasTypeResolver()
hasTypeResolver(
type: ObjectTypeComposer<any, TContext> | GraphQLObjectType
): boolean
getTypeResolvers()
getTypeResolvers(): UnionTypeResolversMap<TSource, TContext>
getTypeResolverCheckFn()
getTypeResolverCheckFn(
type: ObjectTypeComposer<any, TContext> | GraphQLObjectType
): UnionTypeResolverCheckFn<any, TContext>
getTypeResolverNames()
getTypeResolverNames(): string[]
getTypeResolverTypes()
getTypeResolverTypes(): GraphQLObjectType[]
setTypeResolvers()
setTypeResolvers(
typeResolversMap: UnionTypeResolversMap<TSource, TContext>
): this
addTypeResolver()
addTypeResolver(
type: ObjectTypeComposer<any, TContext> | GraphQLObjectType,
checkFn: UnionTypeResolverCheckFn<TSource, TContext>
): this
removeTypeResolver()
removeTypeResolver(
type: ObjectTypeComposer<any, TContext> | GraphQLObjectType
): this
Extensions methods
getExtensions()
getExtensions(): Extensions
setExtensions()
setExtensions(
extensions: Extensions
): this
extendExtensions()
extendExtensions(
extensions: Extensions
): this
clearExtensions()
clearExtensions(): this
getExtension()
getExtension(
extensionName: string
): any
hasExtension()
hasExtension(
extensionName: string
): boolean
setExtension()
setExtension(
extensionName: string,
value: any
): this
removeExtension()
removeExtension(
extensionName: string
): this
Internal type definitions
GraphQLUnionTypeExtended
export type GraphQLUnionTypeExtended<TSource, TContext> = GraphQLUnionType & {
_gqcTypeMap: Map<string, ComposeObjectType>;
_gqcTypeResolvers?: UnionTypeResolversMap<TSource, TContext>;
_gqcExtensions?: Extensions;
};
UnionTypeResolversMap
export type UnionTypeResolversMap<TSource, TContext> = Map<
ComposeObjectType,
UnionTypeResolverCheckFn<TSource, TContext>
>;
UnionTypeResolverCheckFn
export type UnionTypeResolverCheckFn<TSource, TContext> = (
value: TSource,
context: TContext,
info: GraphQLResolveInfo,
) => MaybePromise<boolean | null | void>;
ComposeUnionTypeConfig
export type ComposeUnionTypeConfig<TSource, TContext> = {
name: string;
types?: Thunk<ComposeObjectType[]>;
resolveType?: GraphQLTypeResolver<TSource, TContext> | null;
description?: string | null;
extensions?: Extensions;
};
UnionTypeComposeDefinition
export type UnionTypeComposeDefinition<TSource, TContext> =
| TypeAsString
| ComposeUnionTypeConfig<TSource, TContext>;