InterfaceTypeComposer
Class that helps to create GraphQLInterfaceType
s and provide ability to modify them.
Static methods
static create()
static create<TSrc = any, TCtx = any>(
typeDef: InterfaceTypeComposeDefinition<TSrc, TCtx>,
schemaComposer: SchemaComposer<TCtx>
): InterfaceTypeComposer<TSrc, TCtx>
Create InterfaceTypeComposer
with adding it by name to the SchemaComposer
.
static createTemp()
static createTemp<TSrc = any, TCtx = any>(
typeDef: InterfaceTypeComposeDefinition<TSrc, TCtx>,
schemaComposer: SchemaComposer<TCtx>
): InterfaceTypeComposer<TSrc, TCtx>
Create InterfaceTypeComposer
without adding it to the SchemaComposer
. This method may be usefull in plugins, when you need to create type temporary.
Properties
sc
sc: SchemaComposer<TContext>;
Field methods
hasField()
hasField(
name: string
): boolean
getFields()
getFields(): ComposeFieldConfigMap<TSource, TContext>
getField()
getField(
name: string
): ComposeFieldConfig<TSource, TContext>
getFieldNames()
getFieldNames(): string[]
setFields()
setFields(
fields: ComposeFieldConfigMap<TSource, TContext>
): this
setField()
setField(
name: string,
fieldConfig: ComposeFieldConfig<TSource, TContext>
): this
addFields()
addFields(
newValues: ComposeFieldConfigMap<TSource, TContext>
): this
Add new fields or replace existed in a GraphQL type
removeField()
removeField(
nameOrArray: string | string[]
): this
removeOtherFields()
removeOtherFields(
fieldNameOrArray: string | string[]
): this
reorderFields()
reorderFields(
names: string[]
): this
extendField()
extendField(
fieldName: string,
partialFieldConfig: Partial<ComposeFieldConfigAsObject<TSource, TContext>>
): this
isFieldNonNull()
isFieldNonNull(
fieldName: string
): boolean
getFieldConfig()
getFieldConfig(
fieldName: string
): GraphQLFieldConfig<TSource, TContext>
getFieldType()
getFieldType(
fieldName: string
): GraphQLOutputType
getFieldTC()
getFieldTC(
fieldName: string
):
| ObjectTypeComposer<TSource, TContext>
| InputTypeComposer<TContext>
| EnumTypeComposer<TContext>
| InterfaceTypeComposer<TSource, TContext>
| UnionTypeComposer<TSource, TContext>
| ScalarTypeComposer<TContext>
makeFieldNonNull()
makeFieldNonNull(
fieldNameOrArray: string | string[]
): this
makeFieldNullable()
makeFieldNullable(
fieldNameOrArray: string | string[]
): this
deprecateFields()
deprecateFields(
fields: {
[fieldName: string]: string;
} | string[] | string
): this
getFieldArgs()
getFieldArgs(
fieldName: string
): GraphQLFieldConfigArgumentMap
hasFieldArg()
hasFieldArg(
fieldName: string,
argName: string
): boolean
getFieldArg()
getFieldArg(
fieldName: string,
argName: string
): GraphQLArgumentConfig
getFieldArgType()
getFieldArgType(
fieldName: string,
argName: string
): GraphQLInputType
Type methods
getType()
getType(): GraphQLInterfaceType
getTypePlural()
getTypePlural(): GraphQLList<GraphQLInterfaceType>
getTypeNonNull()
getTypeNonNull(): GraphQLNonNull<GraphQLInterfaceType>
getTypeName()
getTypeName(): string
setTypeName()
setTypeName(
name: string
): this
getDescription()
getDescription(): string
setDescription()
setDescription(
description: string
): this
clone()
clone(
newTypeName: string
): this
InputType methods
getInputType()
getInputType(): GraphQLInputObjectType
hasInputTypeComposer()
hasInputTypeComposer(): boolean
setInputTypeComposer()
setInputTypeComposer(
itc: InputTypeComposer<TContext>
): this
getInputTypeComposer()
getInputTypeComposer(): InputTypeComposer<TContext>
getITC()
getITC(): InputTypeComposer<TContext>
An alias for getInputTypeComposer
removeInputTypeComposer()
removeInputTypeComposer(): this
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(): InterfaceTypeResolversMap<TContext>
getTypeResolverCheckFn()
getTypeResolverCheckFn(
type: ObjectTypeComposer<any, TContext> | GraphQLObjectType
): InterfaceTypeResolverCheckFn<TSource, TContext>
getTypeResolverNames()
getTypeResolverNames(): string[]
getTypeResolverTypes()
getTypeResolverTypes(): GraphQLObjectType[]
setTypeResolvers()
setTypeResolvers(
typeResolversMap: InterfaceTypeResolversMap<TContext>
): this
addTypeResolver()
addTypeResolver<TSrc = any>(
type: ObjectTypeComposer<TSrc, TContext> | GraphQLObjectType,
checkFn: InterfaceTypeResolverCheckFn<TSrc, 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
getFieldExtensions()
getFieldExtensions(
fieldName: string
): Extensions
setFieldExtensions()
setFieldExtensions(
fieldName: string,
extensions: Extensions
): this
extendFieldExtensions()
extendFieldExtensions(
fieldName: string,
extensions: Extensions
): this
clearFieldExtensions()
clearFieldExtensions(
fieldName: string
): this
getFieldExtension()
getFieldExtension(
fieldName: string,
extensionName: string
): any
hasFieldExtension()
hasFieldExtension(
fieldName: string,
extensionName: string
): boolean
setFieldExtension()
setFieldExtension(
fieldName: string,
extensionName: string,
value: any
): this
removeFieldExtension()
removeFieldExtension(
fieldName: string,
extensionName: string
): this
Misc methods
get()
get(
path: string | string[]
): any
Internal type definitions
GraphQLInterfaceTypeExtended
export type GraphQLInterfaceTypeExtended<
TSource,
TContext
> = GraphQLInterfaceType & {
_gqcFields?: ComposeFieldConfigMap<TSource, TContext>;
_gqcInputTypeComposer?: InputTypeComposer<TContext>;
_gqcTypeResolvers?: InterfaceTypeResolversMap<TContext>;
_gqcExtensions?: Extensions;
};
InterfaceTypeResolversMap
export type InterfaceTypeResolversMap<TContext> = Map<
ObjectTypeComposer<any, TContext> | GraphQLObjectType,
InterfaceTypeResolverCheckFn<any, TContext>
>;
InterfaceTypeResolverCheckFn
export type InterfaceTypeResolverCheckFn<TSource, TContext> = (
value: TSource,
context: TContext,
info: GraphQLResolveInfo,
) => MaybePromise<boolean | null | undefined>;
ComposeInterfaceTypeConfig
export type ComposeInterfaceTypeConfig<TSource, TContext> = {
name: string;
fields?: Thunk<ComposeFieldConfigMap<TSource, TContext>>;
resolveType?: GraphQLTypeResolver<TSource, TContext> | null;
description?: string | null;
extensions?: Extensions;
};
InterfaceTypeComposeDefinition
export type InterfaceTypeComposeDefinition<TSource, TContext> =
| TypeAsString
| ComposeInterfaceTypeConfig<TSource, TContext>;