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: InterfaceTypeComposerDefinition<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: InterfaceTypeComposerDefinition<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
schemaComposer
schemaComposer: SchemaComposer<TContext>;
Field methods
getFields()
getFields(): ObjectTypeComposerFieldConfigMap<TSource, TContext>
getFieldNames()
getFieldNames(): string[]
getField()
getField(
name: string
): ObjectTypeComposerFieldConfig<TSource, TContext>
hasField()
hasField(
name: string
): boolean
setFields()
setFields(
fields: ObjectTypeComposerFieldConfigMapDefinition<TSource, TContext>
): this
setField()
setField(
name: string,
fieldConfig: ObjectTypeComposerFieldConfigDefinition<TSource, TContext>
): this
addFields()
addFields(
newValues: ObjectTypeComposerFieldConfigMapDefinition<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<ObjectTypeComposerFieldConfigAsObjectDefinition<TSource, TContext>>
): this
getFieldConfig()
getFieldConfig(
fieldName: string
): GraphQLFieldConfig<TSource, TContext>
getFieldType()
getFieldType(
fieldName: string
): GraphQLOutputType
getFieldTypeName()
getFieldTypeName(
fieldName: string
): string
getFieldTC()
getFieldTC(
fieldName: string
): ComposeNamedOutputType<TContext>
getFieldOTC()
getFieldOTC(
fieldName: string
): ObjectTypeComposer<TSource, TContext>
Alias for getFieldTC()
but returns statically checked ObjectTypeComposer.
If field have other type then error will be thrown.
isFieldNonNull()
isFieldNonNull(
fieldName: string
): boolean
makeFieldNonNull()
makeFieldNonNull(
fieldNameOrArray: string | string[]
): this
makeFieldNullable()
makeFieldNullable(
fieldNameOrArray: string | string[]
): this
isFieldPlural()
isFieldPlural(
fieldName: string
): boolean
makeFieldPlural()
makeFieldPlural(
fieldNameOrArray: string | string[]
): this
makeFieldNonPlural()
makeFieldNonPlural(
fieldNameOrArray: string | string[]
): this
deprecateFields()
deprecateFields(
fields: {
[fieldName: string]: string;
} | string[] | string
): this
getFieldArgs()
getFieldArgs<TArgs = ArgsMap>(
fieldName: string
): ObjectTypeComposerArgumentConfigMap<TArgs>
hasFieldArg()
hasFieldArg(
fieldName: string,
argName: string
): boolean
getFieldArg()
getFieldArg(
fieldName: string,
argName: string
): ObjectTypeComposerArgumentConfig
getFieldArgType()
getFieldArgType(
fieldName: string,
argName: string
): GraphQLInputType
getFieldArgTypeName()
getFieldArgTypeName(
fieldName: string,
argName: string
): string
getFieldArgTC()
getFieldArgTC(
fieldName: string,
argName: string
): ComposeNamedInputType<TContext>
Automatically unwrap from List, NonNull, ThunkComposer It's important! Cause greatly helps to modify args types in a real code without manual unwrap writing.
If you need to work with wrappers, you may use the following code:
isFieldArgPlural()
โ checks is arg wrapped in ListComposer or not
makeFieldArgPlural()
โ for arg wrapping in ListComposer
makeFieldArgNonPlural()
โ for arg unwrapping from ListComposer
isFieldArgNonNull()
โ checks is arg wrapped in NonNullComposer or not
makeFieldArgNonNull()
โ for arg wrapping in NonNullComposer
makeFieldArgNullable()
โ for arg unwrapping from NonNullComposer
getFieldArgITC()
getFieldArgITC(
fieldName: string,
argName: string
): InputTypeComposer<TContext>
Alias for getFieldArgTC()
but returns statically checked InputTypeComposer.
If field have other type then error will be thrown.
setFieldArgs()
setFieldArgs(
fieldName: string,
args: ObjectTypeComposerArgumentConfigMapDefinition<any>
): this
addFieldArgs()
addFieldArgs(
fieldName: string,
newArgs: ObjectTypeComposerArgumentConfigMapDefinition<any>
): this
setFieldArg()
setFieldArg(
fieldName: string,
argName: string,
argConfig: ObjectTypeComposerArgumentConfig
): this
isFieldArgPlural()
isFieldArgPlural(
fieldName: string,
argName: string
): boolean
makeFieldArgPlural()
makeFieldArgPlural(
fieldName: string,
argNameOrArray: string | string[]
): this
makeFieldArgNonPlural()
makeFieldArgNonPlural(
fieldName: string,
argNameOrArray: string | string[]
): this
isFieldArgNonNull()
isFieldArgNonNull(
fieldName: string,
argName: string
): boolean
makeFieldArgNonNull()
makeFieldArgNonNull(
fieldName: string,
argNameOrArray: string | string[]
): this
makeFieldArgNullable()
makeFieldArgNullable(
fieldName: string,
argNameOrArray: string | string[]
): this
Type methods
getType()
getType(): GraphQLInterfaceType
getTypePlural()
getTypePlural(): ListComposer<this>
getTypeNonNull()
getTypeNonNull(): NonNullComposer<this>
getTypeName()
getTypeName(): string
setTypeName()
setTypeName(
name: string
): this
getDescription()
getDescription(): string
setDescription()
setDescription(
description: string
): this
clone()
clone(
newTypeNameOrTC: string | InterfaceTypeComposer<any, any>
): this
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: GraphQLInterfaceType | GraphQLObjectType | InterfaceTypeComposer<any, any> | ObjectTypeComposer<any, any>
): InterfaceTypeComposer<TSource, TContext>
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(): InterfaceTypeComposerResolversMap<TContext>
getTypeResolverCheckFn()
getTypeResolverCheckFn(
type: ObjectTypeComposer<any, TContext> | GraphQLObjectType
): InterfaceTypeComposerResolverCheckFn<TSource, TContext>
getTypeResolverNames()
getTypeResolverNames(): string[]
getTypeResolverTypes()
getTypeResolverTypes(): GraphQLObjectType[]
setTypeResolvers()
setTypeResolvers(
typeResolversMap: InterfaceTypeComposerResolversMap<TContext>
): this
addTypeResolver()
addTypeResolver<TSrc = any>(
type: ObjectTypeComposer<TSrc, TContext> | GraphQLObjectType,
checkFn: InterfaceTypeComposerResolverCheckFn<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
getFieldArgExtensions()
getFieldArgExtensions(
fieldName: string,
argName: string
): Extensions
setFieldArgExtensions()
setFieldArgExtensions(
fieldName: string,
argName: string,
extensions: Extensions
): this
extendFieldArgExtensions()
extendFieldArgExtensions(
fieldName: string,
argName: string,
extensions: Extensions
): this
clearFieldArgExtensions()
clearFieldArgExtensions(
fieldName: string,
argName: string
): this
getFieldArgExtension()
getFieldArgExtension(
fieldName: string,
argName: string,
extensionName: string
): any
hasFieldArgExtension()
hasFieldArgExtension(
fieldName: string,
argName: string,
extensionName: string
): boolean
setFieldArgExtension()
setFieldArgExtension(
fieldName: string,
argName: string,
extensionName: string,
value: any
): this
removeFieldArgExtension()
removeFieldArgExtension(
fieldName: string,
argName: string,
extensionName: string
): this
Directive methods
getDirectives()
getDirectives(): ExtensionsDirective[]
getDirectiveNames()
getDirectiveNames(): string[]
getDirectiveByName()
getDirectiveByName(
directiveName: string
): DirectiveArgs | void
getDirectiveById()
getDirectiveById(
idx: number
): DirectiveArgs | void
getFieldDirectives()
getFieldDirectives(
fieldName: string
): ExtensionsDirective[]
getFieldDirectiveNames()
getFieldDirectiveNames(
fieldName: string
): string[]
getFieldDirectiveByName()
getFieldDirectiveByName(
fieldName: string,
directiveName: string
): DirectiveArgs | void
getFieldDirectiveById()
getFieldDirectiveById(
fieldName: string,
idx: number
): DirectiveArgs | void
getFieldArgDirectives()
getFieldArgDirectives(
fieldName: string,
argName: string
): ExtensionsDirective[]
getFieldArgDirectiveNames()
getFieldArgDirectiveNames(
fieldName: string,
argName: string
): string[]
getFieldArgDirectiveByName()
getFieldArgDirectiveByName(
fieldName: string,
argName: string,
directiveName: string
): DirectiveArgs | void
getFieldArgDirectiveById()
getFieldArgDirectiveById(
fieldName: string,
argName: string,
idx: number
): DirectiveArgs | void
Misc methods
get()
get(
path: string | string[]
): TypeInPath<TContext> | void
Internal type definitions
InterfaceTypeComposerDefinition
export type InterfaceTypeComposerDefinition<TSource, TContext> =
| TypeAsString
| TypeDefinitionString
| InterfaceTypeComposerAsObjectDefinition<TSource, TContext>
| GraphQLInterfaceType
| Readonly<InterfaceTypeComposerThunked<any, TContext>>;
InterfaceTypeComposerAsObjectDefinition
export type InterfaceTypeComposerAsObjectDefinition<TSource, TContext> = {
name: string;
fields?: ObjectTypeComposerFieldConfigMapDefinition<TSource, TContext>;
resolveType?: null | GraphQLTypeResolver<TSource, TContext>;
description?: null | string;
extensions?: Extensions;
};
InterfaceTypeComposerResolversMap
export type InterfaceTypeComposerResolversMap<TContext> = Map<
ObjectTypeComposer<any, TContext> | GraphQLObjectType,
InterfaceTypeComposerResolverCheckFn<any, TContext>
>;
InterfaceTypeComposerResolverCheckFn
export type InterfaceTypeComposerResolverCheckFn<TSource, TContext> = (
value: TSource,
context: TContext,
info: GraphQLResolveInfo
) => MaybePromise<boolean | null | void>;
InterfaceTypeComposerThunked
export type InterfaceTypeComposerThunked<TReturn, TContext> =
| InterfaceTypeComposer<TReturn, TContext>
| ThunkComposer<InterfaceTypeComposer<TReturn, TContext>, GraphQLInterfaceType>;