Bird
0
0

How can you combine input types with enums to restrict input values? Choose the correct example.

hard📝 Application Q9 of 15
GraphQL - Schema Definition Language (SDL)
How can you combine input types with enums to restrict input values? Choose the correct example.
Ascalar Role { ADMIN USER } input UserInput { name: String!, role: Role }
Binput Role { ADMIN USER } input UserInput { name: String!, role: Role! }
Cenum RoleInput { ADMIN USER } input UserInput { name: String!, role: RoleInput }
Denum Role { ADMIN USER } input UserInput { name: String!, role: Role! }
Step-by-Step Solution
Solution:
  1. Step 1: Understand enum and input type usage

    Enums define a set of allowed values. Input types can use enums as field types.
  2. Step 2: Check syntax correctness

    enum Role { ADMIN USER } input UserInput { name: String!, role: Role! } correctly defines enum Role and uses it in input UserInput with non-null role field.
  3. Final Answer:

    enum Role { ADMIN USER } input UserInput { name: String!, role: Role! } -> Option D
  4. Quick Check:

    Use enums as field types in input types [OK]
Quick Trick: Use enums inside input types to restrict values [OK]
Common Mistakes:
  • Defining enums as input types
  • Using scalar instead of enum for fixed values
  • Omitting exclamation mark for required enum fields

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More GraphQL Quizzes