Recall & Review
beginner
What is an Enum type in GraphQL?
An Enum type in GraphQL is a special kind of scalar that restricts a field to a set of predefined constant values. It helps ensure only valid values are used.
Click to reveal answer
beginner
How do you define an Enum type in GraphQL schema?
You define an Enum type using the
enum keyword followed by the name and a list of allowed values inside curly braces. For example:<br>enum Color { RED GREEN BLUE }Click to reveal answer
intermediate
Why use Enum types instead of strings in GraphQL?
Enums provide a fixed set of allowed values, which helps catch errors early, improves API clarity, and makes client-server communication more predictable compared to free-form strings.
Click to reveal answer
intermediate
Can Enum types have descriptions for each value in GraphQL?
Yes, you can add descriptions to each Enum value using string comments above each value. This helps document the purpose of each option for API users.
Click to reveal answer
intermediate
How does GraphQL handle invalid Enum values in queries?
If a query provides a value not defined in the Enum, GraphQL returns an error and does not execute the query, ensuring only valid Enum values are accepted.
Click to reveal answer
Which keyword is used to define an Enum type in GraphQL?
✗ Incorrect
The
enum keyword is used to define Enum types in GraphQL.What happens if a query uses a value not in the Enum type?
✗ Incorrect
GraphQL returns an error if a value outside the Enum's allowed set is used.
Why are Enum types useful in GraphQL?
✗ Incorrect
Enums restrict values to a fixed set, improving validation and clarity.
Can Enum values have descriptions in GraphQL schema?
✗ Incorrect
You can add descriptions to Enum values using comments above them.
Which of these is a valid Enum definition?
✗ Incorrect
Option A uses the correct GraphQL Enum syntax.
Explain what an Enum type is in GraphQL and why it is useful.
Think about how you limit choices to a list of options.
You got /3 concepts.
Describe how to define an Enum type in a GraphQL schema with an example.
Remember the syntax starts with 'enum' followed by the name.
You got /4 concepts.