Bird
0
0

You want to model a social network where users can follow many other users. Which GraphQL type definition correctly models this relationship?

hard📝 Application Q15 of 15
GraphQL - Type Relationships
You want to model a social network where users can follow many other users. Which GraphQL type definition correctly models this relationship?
Atype User { id: ID name: String followers: [User] following: [User] }
Btype User { id: ID name: String followers: User following: User }
Ctype User { id: ID name: String followers: String following: String }
Dtype User { id: ID name: String followers: [String] following: [String] }
Step-by-Step Solution
Solution:
  1. Step 1: Understand the relationship type

    Users can follow many other users, so followers and following must be lists of User type.
  2. Step 2: Check each option's field types

    type User { id: ID name: String followers: [User] following: [User] } correctly uses lists of User for both followers and following. Others use single User or String types incorrectly.
  3. Final Answer:

    type User { id: ID name: String followers: [User] following: [User] } -> Option A
  4. Quick Check:

    Many-to-many = lists of same type [OK]
Quick Trick: Use lists of the same type for many-to-many relationships [OK]
Common Mistakes:
  • Using single User type for multiple followers
  • Using String instead of User type
  • Confusing field types with scalar lists

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More GraphQL Quizzes