Bird
0
0

Examine this GraphQL schema snippet for a one-to-many relationship:

medium📝 Debug Q6 of 15
GraphQL - Type Relationships
Examine this GraphQL schema snippet for a one-to-many relationship:
type Customer { id: ID! orders: Order! } type Order { id: ID! customer: Customer! }
What is the issue here?
AThe 'orders' field should be a list type to represent multiple orders.
BThe 'customer' field in Order should be a list type.
CThe 'id' fields should not be non-nullable.
DThe schema is correct as is.
Step-by-Step Solution
Solution:
  1. Step 1: Understand the relationship

    A Customer can have many Orders, so orders field must be a list.
  2. Step 2: Check schema types

    orders: Order! means a single Order, not multiple.
  3. Step 3: Correct representation

    It should be orders: [Order!]! to represent many orders properly.
  4. Final Answer:

    Option A -> Option A
  5. Quick Check:

    List type needed on 'many' side [OK]
Quick Trick: Use list type for 'many' side fields [OK]
Common Mistakes:
  • Using single object instead of list for multiple related items
  • Misunderstanding non-null vs list types
  • Assuming one-to-many means both sides are single

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More GraphQL Quizzes