InputTypeComposer
Static methods
static create()
static create<TCtx = any>(
typeDef: InputTypeComposerDefinition,
schemaComposer: SchemaComposer<TCtx>
): InputTypeComposer<TCtx>
Create InputTypeComposer
with adding it by name to the SchemaComposer
.
static createTemp()
static createTemp<TCtx = any>(
typeDef: InputTypeComposerDefinition,
schemaComposer: SchemaComposer<TCtx>
): InputTypeComposer<TCtx>
Create InputTypeComposer
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(): InputTypeComposerFieldConfigMap
getFieldNames()
getFieldNames(): string[]
hasField()
hasField(
fieldName: string
): boolean
setFields()
setFields(
fields: InputTypeComposerFieldConfigMapDefinition
): this
setField()
setField(
fieldName: string,
fieldConfig: Thunk<InputTypeComposerFieldConfigDefinition>
): this
addFields()
addFields(
newFields: InputTypeComposerFieldConfigMapDefinition
): this
Add new fields or replace existed in a GraphQL type
addNestedFields()
addNestedFields(
newFields: InputTypeComposerFieldConfigMapDefinition
): this
Add new fields or replace existed (where field name may have dots)
getField()
getField(
fieldName: string
): InputTypeComposerFieldConfig
removeField()
removeField(
fieldNameOrArray: string | string[]
): this
removeOtherFields()
removeOtherFields(
fieldNameOrArray: string | string[]
): this
extendField()
extendField(
fieldName: string,
partialFieldConfig: Partial<InputTypeComposerFieldConfigAsObjectDefinition>
): this
reorderFields()
reorderFields(
names: string[]
): this
isFieldNonNull()
isFieldNonNull(
fieldName: string
): boolean
getFieldConfig()
getFieldConfig(
fieldName: string
): GraphQLInputFieldConfig
getFieldType()
getFieldType(
fieldName: string
): GraphQLInputType
getFieldTypeName()
getFieldTypeName(
fieldName: string
): string
getFieldTC()
getFieldTC(
fieldName: string
): ComposeNamedInputType<TContext>
Automatically unwrap from List, NonNull, ThunkComposer It's important! Cause greatly helps to modify fields types in a real code without manual unwrap writing.
If you need to work with wrappers, you may use the following code:
TC.getField().type
// returns real wrapped TypeComposerTC.isFieldNonNull()
// checks is field NonNull or notTC.makeFieldNonNull()
// for wrapping in NonNullComposerTC.makeFieldNullable()
// for unwrapping from NonNullComposerTC.isFieldPlural()
// checks is field wrapped in ListComposer or notTC.makeFieldPlural()
// for wrapping in ListComposerTC.makeFieldNonPlural()
// for unwrapping from ListComposer
getFieldITC()
getFieldITC(
fieldName: string
): InputTypeComposer<TContext>
Alias for getFieldTC()
but returns statically checked InputTypeComposer.
If field have other type then error will be thrown.
makeFieldNonNull()
makeFieldNonNull(
fieldNameOrArray: string | string[]
): this
makeRequired()
makeRequired(
fieldNameOrArray: string | string[]
): this
An alias for makeFieldNonNull()
makeFieldNullable()
makeFieldNullable(
fieldNameOrArray: string | string[]
): this
makeOptional()
makeOptional(
fieldNameOrArray: string | string[]
): this
An alias for makeFieldNullable()
isFieldPlural()
isFieldPlural(
fieldName: string
): boolean
makeFieldPlural()
makeFieldPlural(
fieldNameOrArray: string | string[]
): this
makeFieldNonPlural()
makeFieldNonPlural(
fieldNameOrArray: string | string[]
): this
Type methods
getType()
getType(): GraphQLInputObjectType
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 | InputTypeComposer<any>
): InputTypeComposer<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: GraphQLInputObjectType | InputTypeComposer<any>
): 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
Directive methods
Directive methods are usefull if you declare your schemas via SDL.
Users who actively use graphql-tools
can open new abilities for writing
your own directive handlers.
If you create your schemas via config objects, then probably you
no need in directives
. Instead directives better to use extensions
.
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
Misc methods
get()
get(
path: string | string[]
): TypeInPath<TContext> | void
Internal type definitions
InputTypeComposerDefinition
export type InputTypeComposerDefinition =
| TypeAsString
| TypeDefinitionString
| InputTypeComposerAsObjectDefinition
| Readonly<GraphQLInputObjectType>;
InputTypeComposerAsObjectDefinition
export type InputTypeComposerAsObjectDefinition = {
name: string;
fields: Thunk<InputTypeComposerFieldConfigMapDefinition>;
description?: null | string;
extensions?: Extensions;
};
InputTypeComposerFieldConfigMap
export type InputTypeComposerFieldConfigMap = ObjMap<InputTypeComposerFieldConfig>;
InputTypeComposerFieldConfigMapDefinition
export type InputTypeComposerFieldConfigMapDefinition = ObjMapReadOnly<
Thunk<InputTypeComposerFieldConfigDefinition>
>;
InputTypeComposerFieldConfigDefinition
export type InputTypeComposerFieldConfigDefinition =
| InputTypeComposerFieldConfigAsObjectDefinition
| ComposeInputTypeDefinition
| Readonly<ComposeInputType>;
InputTypeComposerFieldConfigAsObjectDefinition
export type InputTypeComposerFieldConfigAsObjectDefinition = {
type: Thunk<ComposeInputTypeDefinition>;
defaultValue?: any;
description?: string | null;
extensions?: Extensions;
[key: string]: any;
};
InputTypeComposerFieldConfig
export type InputTypeComposerFieldConfig = {
type: ComposeInputType;
defaultValue?: any;
description?: string | null;
astNode?: InputValueDefinitionNode | null;
extensions?: Extensions;
[key: string]: any;
};
InputTypeComposerThunked
export type InputTypeComposerThunked<TContext> =
| InputTypeComposer<TContext>
| ThunkComposer<InputTypeComposer<TContext>, GraphQLInputType>;