Bird
0
0

How should you define a GraphQL object type Group that contains a field participants which is a list of User objects?

hard📝 Application Q9 of 15
GraphQL - Schema Definition Language (SDL)
How should you define a GraphQL object type Group that contains a field participants which is a list of User objects?
Atype Group { participants: List<User> }
Btype Group { participants: User }
Ctype Group { participants: User[] }
Dtype Group { participants: [User] }
Step-by-Step Solution
Solution:
  1. Step 1: Recall list syntax in GraphQL

    Lists are denoted by square brackets around the type, e.g., [User].
  2. Step 2: Analyze options

    type Group { participants: [User] } correctly uses [User]. Options C and D use invalid syntax. type Group { participants: User } defines a single User, not a list.
  3. Final Answer:

    A -> Option D
  4. Quick Check:

    Lists use square brackets in GraphQL [OK]
Quick Trick: Use [Type] for lists in GraphQL [OK]
Common Mistakes:
  • Using array syntax like User[]
  • Using generic List syntax
  • Defining a single object instead of a list

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More GraphQL Quizzes