EnumTypeComposer
EnumTypeComposer
is a class which helps to create and modify GraphQLEnumType
.
Static methods
static create()
static create<TCtx = any>(
typeDef: EnumTypeComposerDefinition,
schemaComposer: SchemaComposer<TCtx>
): EnumTypeComposer<TCtx>
Create EnumTypeComposer
with adding it by name to the SchemaComposer
. This type became avaliable in SDL by its name.
static createTemp()
static createTemp<TCtx = any>(
typeDef: EnumTypeComposerDefinition,
schemaComposer: SchemaComposer<TCtx>
): EnumTypeComposer<TCtx>
Create EnumTypeComposer
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>;
Value methods
hasField()
hasField(
name: string
): boolean
For similar naming with ObjectTypeComposer
and InputTypeComposer
for working with Enum values used methods with name *field*
instead of *value*
.
getFields()
getFields(): EnumTypeComposerValueConfigMap
getField()
getField(
name: string
): EnumTypeComposerValueConfig
getFieldNames()
getFieldNames(): string[]
setFields()
setFields(
values: EnumTypeComposerValueConfigMapDefinition
): this
Completely replace all values in the type with a new set.
setField()
setField(
name: string,
valueConfig: EnumTypeComposerValueConfigDefinition
): this
addFields()
addFields(
newValues: EnumTypeComposerValueConfigMapDefinition
): this
Add new fields or replace existed, other fields keep untouched.
removeField()
removeField(
nameOrArray: string | string[]
): this
Remove one value by its name, or by array of field names.
removeOtherFields()
removeOtherFields(
fieldNameOrArray: string | string[]
): this
Keep only provided fields in type, other fields will be removed.
reorderFields()
reorderFields(
names: string[]
): this
extendField()
extendField(
name: string,
partialValueConfig: Partial<EnumTypeComposerValueConfigDefinition>
): this
deprecateFields()
deprecateFields(
fields: {
[fieldName: string]: string;
} | string[] | string
): this
Mark value or map of values as deprecated
Type methods
getType()
getType(): GraphQLEnumType
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 | EnumTypeComposer<any>
): EnumTypeComposer<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: GraphQLEnumType | EnumTypeComposer<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
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
Internal type definitions
EnumTypeComposerDefinition
export type EnumTypeComposerDefinition =
| TypeAsString
| EnumTypeComposerAsObjectDefinition
| GraphQLEnumType;
EnumTypeComposerAsObjectDefinition
export type EnumTypeComposerAsObjectDefinition = {
name: string;
values?: EnumTypeComposerValueConfigMapDefinition;
description?: string | null;
extensions?: Extensions;
};
EnumTypeComposerValueConfig
export type EnumTypeComposerValueConfig = {
value: any /* T */;
deprecationReason?: string | null;
description?: string | null;
astNode?: EnumValueDefinitionNode | null;
extensions?: Extensions;
[key: string]: any;
};
EnumTypeComposerValueConfigDefinition
export type EnumTypeComposerValueConfigDefinition = {
value?: any;
deprecationReason?: string | null;
description?: string | null;
extensions?: Extensions;
[key: string]: any;
};
EnumTypeComposerValueConfigMap
export type EnumTypeComposerValueConfigMap = ObjMap<EnumTypeComposerValueConfig>;
EnumTypeComposerValueConfigMapDefinition
export type EnumTypeComposerValueConfigMapDefinition = ObjMapReadOnly<
EnumTypeComposerValueConfigDefinition
>;