EnumTypeComposer
EnumTypeComposer
is a class which helps to create and modify GraphQLEnumType
.
Static methods
static create()
static create<TCtx = any>(
typeDef: EnumTypeComposeDefinition,
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: EnumTypeComposeDefinition,
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(): GraphQLEnumValueConfigMap
getField()
getField(
name: string
): GraphQLEnumValueConfig
getFieldNames()
getFieldNames(): string[]
setFields()
setFields(
values: GraphQLEnumValueConfigMap
): this
Completely replace all values in the type with a new set.
setField()
setField(
name: string,
valueConfig: GraphQLEnumValueConfig
): this
addFields()
addFields(
newValues: GraphQLEnumValueConfigMap
): 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<GraphQLEnumValueConfig>
): this
deprecateFields()
deprecateFields(
fields: {
[fieldName: string]: string;
} | string[] | string
): this
Mark value or map of values as deprecated
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
Type methods
getType()
getType(): GraphQLEnumType
getTypePlural()
getTypePlural(): GraphQLList<GraphQLEnumType>
getTypeNonNull()
getTypeNonNull(): GraphQLNonNull<GraphQLEnumType>
getTypeName()
getTypeName(): string
setTypeName()
setTypeName(
name: string
): this
getDescription()
getDescription(): string
setDescription()
setDescription(
description: string
): this
clone()
clone(
newTypeName: string
): EnumTypeComposer<TContext>
Internal type definitions
ComposeEnumTypeConfig
export type ComposeEnumTypeConfig = GraphQLEnumTypeConfig & {
extensions?: Extensions;
};
EnumTypeComposeDefinition
export type EnumTypeComposeDefinition =
| TypeAsString
| ComposeEnumTypeConfig
| GraphQLEnumType;
GraphQLEnumTypeExtended
export type GraphQLEnumTypeExtended = GraphQLEnumType & {
_gqcExtensions?: Extensions;
};