Bird
0
0

Which schema correctly models this with bidirectional fields?

hard📝 Application Q15 of 15
GraphQL - Type Relationships
You want to model a bidirectional relationship between Employee and Manager where each employee has one manager, and each manager can have many employees. Which schema correctly models this with bidirectional fields?
Atype Employee { manager: Employee } type Manager { employees: [Manager] }
Btype Employee { manager: Manager } type Manager { employees: [Employee] }
Ctype Employee { manager: Manager } type Manager { employees: Employee }
Dtype Employee { manager: [Manager] } type Manager { employees: Employee }
Step-by-Step Solution
Solution:
  1. Step 1: Understand the relationship

    Each employee has one manager (single), each manager has many employees (list).
  2. Step 2: Match schema fields to this

    Employee's manager is a single Manager. Manager's employees is a list of Employee.
  3. Final Answer:

    type Employee { manager: Manager } type Manager { employees: [Employee] } -> Option B
  4. Quick Check:

    One-to-many bidirectional = single on one side, list on other [OK]
Quick Trick: One side single type, other side list type for one-to-many [OK]
Common Mistakes:
  • Swapping list and single types
  • Using wrong types for fields
  • Confusing employee and manager roles

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More GraphQL Quizzes