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: UnionTypeComposerDefinition<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: UnionTypeComposerDefinition<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: ObjectTypeComposerDefinition<any, TContext>
): boolean
getTypes()
getTypes(): Array<ObjectTypeComposerThunked<TSource, TContext>>
getTypeNames()
getTypeNames(): string[]
clearTypes()
clearTypes(): this
setTypes()
setTypes(
types: ReadonlyArray<ObjectTypeComposerThunked<TSource, TContext> | ObjectTypeComposerDefinition<any, TContext>>
): this
addType()
addType(
type: ObjectTypeComposerThunked<any, TContext> | ObjectTypeComposerDefinition<any, TContext>
): this
addTypes()
addTypes(
types: ReadonlyArray<ObjectTypeComposerThunked<any, TContext> | ObjectTypeComposerDefinition<any, TContext>>
): this
removeType()
removeType(
nameOrArray: string | string[]
): this
removeOtherTypes()
removeOtherTypes(
nameOrArray: string | string[]
): this
Type methods
getType()
getType(): GraphQLUnionType
getTypePlural()
getTypePlural(): ListComposer<UnionTypeComposer<TSource, TContext>>
getTypeNonNull()
getTypeNonNull(): NonNullComposer<UnionTypeComposer<TSource, TContext>>
getTypeName()
getTypeName(): string
setTypeName()
setTypeName(
name: string
): this
getDescription()
getDescription(): string
setDescription()
setDescription(
description: string
): this
clone()
clone(
newTypeNameOrTC: string | UnionTypeComposer<any, any>
): UnionTypeComposer<TSource, TContext>
You may clone this type with a new provided name as string. Or you may provide a new TypeComposer which will get all clonned settings from this type.
merge()
merge(
type: GraphQLUnionType | UnionTypeComposer<any, any>
): this
ResolveType methods
getResolveType()
getResolveType(): GraphQLTypeResolver<TSource, TContext> | void | null
setResolveType()
setResolveType(
fn: GraphQLTypeResolver<TSource, TContext> | void | null
): this
hasTypeResolver()
hasTypeResolver(
type: ObjectTypeComposerThunked<any, TContext> | ObjectTypeComposerDefinition<any, TContext>
): boolean
getTypeResolvers()
getTypeResolvers(): UnionTypeComposerResolversMap<TSource, TContext>
getTypeResolverCheckFn()
getTypeResolverCheckFn(
type: ObjectTypeComposerThunked<any, TContext> | ObjectTypeComposerDefinition<any, TContext>
): UnionTypeComposerResolverCheckFn<any, TContext>
getTypeResolverNames()
getTypeResolverNames(): string[]
getTypeResolverTypes()
getTypeResolverTypes(): Array<ObjectTypeComposerThunked<any, TContext>>
setTypeResolvers()
setTypeResolvers(
typeResolversMap: UnionTypeComposerResolversMapDefinition<TSource, TContext>
): this
addTypeResolver()
addTypeResolver(
type: ObjectTypeComposerDefinition<any, TContext>,
checkFn: UnionTypeComposerResolverCheckFn<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
Directive methods
getDirectives()
getDirectives(): ExtensionsDirective[]
getDirectiveNames()
getDirectiveNames(): string[]
getDirectiveByName()
getDirectiveByName(
directiveName: string
): DirectiveArgs | void
getDirectiveById()
getDirectiveById(
idx: number
): DirectiveArgs | void
Internal type definitions
UnionTypeComposerDefinition
export type UnionTypeComposerDefinition<TSource, TContext> =
| TypeAsString
| TypeDefinitionString
| UnionTypeComposerAsObjectDefinition<TSource, TContext>
| GraphQLUnionType;
UnionTypeComposerAsObjectDefinition
export type UnionTypeComposerAsObjectDefinition<TSource, TContext> = {
name: string;
types?: Thunk<ReadonlyArray<ObjectTypeComposerDefinition<any, TContext>> | null>;
resolveType?: GraphQLTypeResolver<TSource, TContext> | null;
description?: string | null;
extensions?: Extensions;
};
UnionTypeComposerResolversMap
export type UnionTypeComposerResolversMap<TSource, TContext> = Map<
ObjectTypeComposerThunked<TSource, TContext>,
UnionTypeComposerResolverCheckFn<TSource, TContext>
>;
UnionTypeComposerResolversMapDefinition
export type UnionTypeComposerResolversMapDefinition<TSource, TContext> =
| Map<
ObjectTypeComposerThunked<any, TContext> | ObjectTypeComposerDefinition<any, TContext>,
UnionTypeComposerResolverCheckFn<TSource, TContext>
>
| Readonly<UnionTypeComposerResolversMap<TSource, TContext>>;
UnionTypeComposerResolverCheckFn
export type UnionTypeComposerResolverCheckFn<TSource, TContext> = (
value: TSource,
context: TContext,
info: GraphQLResolveInfo
) => MaybePromise<boolean | null | void>;
UnionTypeComposerThunked
export type UnionTypeComposerThunked<TReturn, TContext> =
| UnionTypeComposer<TReturn, TContext>
| ThunkComposer<UnionTypeComposer<TReturn, TContext>, GraphQLUnionType>;