Bird
0
0

If you run this query:

medium📝 query result Q5 of 15
GraphQL - Type Relationships
If you run this query:
{ order { customer { name } } }

With schema:
type Order { customer: Customer } type Customer { name: String }

What is the expected output?
AThe customer's name for the order
BAn error due to missing orders field
CList of all customers
DOrder ID only
Step-by-Step Solution
Solution:
  1. Step 1: Understand the query fields

    The query asks for an order's customer and that customer's name.
  2. Step 2: Match schema fields

    Order has a customer field of type Customer, which has a name field, so the query returns the customer's name.
  3. Final Answer:

    The customer's name for the order -> Option A
  4. Quick Check:

    Nested fields return nested data [OK]
Quick Trick: Nested fields fetch nested related data [OK]
Common Mistakes:
  • Expecting list of customers instead of one
  • Confusing order fields with customer fields
  • Assuming error without missing fields

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More GraphQL Quizzes