⬡ GraphQL Intermediate

What are GraphQL enums?

Answer

Enums (enumeration types) in GraphQL represent a set of allowed string values for a field. They are declared with the enum keyword: enum Role { ADMIN EDITOR VIEWER }. Enum values are validated by the schema — passing an invalid value causes a schema validation error. Enums are internally represented as strings but are type-safe at the schema level. They're useful for status fields (OrderStatus: PENDING, PROCESSING, SHIPPED, DELIVERED), user roles, sort directions (OrderDirection: ASC, DESC), and any other fields with a finite set of valid values. Unlike scalars, enum values are visible in introspection.