04 / 10

What are Enum types?

Difficulty: 5/10
enum definition, schema evolution, federation consistency

Enum types, also known as enumeration types, are a special kind of scalar that is restricted to a particular set of allowed values.

This allows you to:
  1. 1

    Validate that any arguments of this type are one of the allowed values

  2. 2

    Communicate through the type system that a field will always be one of a finite set of values

Here’s what an Enum type definition looks like in SDL:

Scenario Questions

0-2 years experience

  1. 1We need to add a new status field to our GraphQL schema that can only be 'OPEN', 'CLOSED', or 'PENDING'. How would you define this using an enum, and what would a client query look like?
  2. 2If a client sends a value not listed in the enum, what does GraphQL do, and how would you handle that in your resolver?

2-5 years experience

  1. 1Our product team wants to deprecate the 'PENDING' value in the OrderStatus enum and replace it with 'IN_REVIEW'. How would you modify the schema to support this change without breaking existing clients?
  2. 2During testing we noticed that a mutation is failing because the enum value sent from the frontend is in lowercase ('open' instead of 'OPEN'). How would you debug and fix this issue?

5-8 years experience

  1. 1We have a federated GraphQL architecture with multiple services each defining overlapping enums. What strategies would you use to keep enum definitions consistent across services, and what are the trade‑offs?
  2. 2A high‑traffic query includes an enum filter on a large dataset, and we see performance degradation. How would you investigate whether the enum is causing the issue and what optimizations could be applied at the schema or resolver level?

8+ years experience

  1. 1Our organization is migrating from a monolithic GraphQL server to a micro‑service mesh. How would you approach versioning and evolving enums across many teams to avoid breaking changes over time?
  2. 2We need to expose a public GraphQL API while maintaining internal enums that include sensitive internal states. How would you design the schema to hide internal enum values yet keep the internal services functional?

Follow-up Questions

  • What happens if you omit the enum definition entirely and use a string instead?
  • Can you explain the difference between deprecating an enum value and removing it?
  • How would you test that your enum changes don’t break existing clients?
Share

Share via WhatsApp, X, Facebook, LinkedIn or copy link. Open Graph preview enabled.