Skip to main content

GraphQLEnumType

Enum Type Definition

Some leaf values of requests and input values are Enums. GraphQL coerces Enum values as strings, however internally Enums can be represented by any kind of type, often integers.

Example:

const RGBType = new GraphQLEnumType({
name: 'RGB',
values: {
RED: { value: 0 },
GREEN: { value: 1 },
BLUE: { value: 2 }
}
});

Note: If a value is not provided in a definition, the name of the enum value will be used as its internal value.

Implements

  • GraphQLSchemaElement

Index

Constructors

constructor

Properties

astNode

astNode: Maybe<EnumTypeDefinitionNode>

description

description: Maybe<string>

extensionASTNodes

extensionASTNodes: readonly EnumTypeExtensionNode[]

extensions

extensions: Readonly<GraphQLEnumTypeExtensions>

name

name: string

Accessors

[toStringTag]

  • get [toStringTag](): string
  • Returns string

Methods

coerceInputLiteral

  • coerceInputLiteral(valueNode: ConstValueNode, hideSuggestions?: Maybe<boolean>): any
  • Parameters

    Returns any

coerceInputValue

  • coerceInputValue(inputValue: unknown, hideSuggestions?: Maybe<boolean>): any
  • Parameters

    • inputValue: unknown
    • optionalhideSuggestions: Maybe<boolean>

    Returns any

coerceOutputValue

  • coerceOutputValue(outputValue: unknown): Maybe<string>
  • Parameters

    • outputValue: unknown

    Returns Maybe<string>

getValue

getValues

parseLiteral

  • parseLiteral(valueNode: ValueNode, _variables: Maybe<ObjMap<unknown>>, hideSuggestions?: Maybe<boolean>): any
  • @deprecated

    use coerceInputLiteral() instead, parseLiteral() will be removed in v18


    Parameters

    • valueNode: ValueNode
    • _variables: Maybe<ObjMap<unknown>>
    • optionalhideSuggestions: Maybe<boolean>

    Returns any

parseValue

  • parseValue(inputValue: unknown, hideSuggestions?: Maybe<boolean>): any
  • @deprecated

    use coerceInputValue() instead, parseValue() will be removed in v18


    Parameters

    • inputValue: unknown
    • optionalhideSuggestions: Maybe<boolean>

    Returns any

serialize

  • serialize(outputValue: unknown): Maybe<string>
  • @deprecated

    use coerceOutputValue() instead, serialize() will be removed in v18


    Parameters

    • outputValue: unknown

    Returns Maybe<string>

toConfig

  • toConfig(): GraphQLEnumTypeNormalizedConfig
  • Returns GraphQLEnumTypeNormalizedConfig

toJSON

  • toJSON(): string
  • Returns string

toString

  • toString(): string
  • Returns string

valueToLiteral