Bird
0
0

How should you implement the customer resolver to correctly use resolver chains?

hard📝 Application Q15 of 15
GraphQL - Resolvers
You want to fetch a list of orders with their customer names using resolver chains. The orders resolver returns an array of orders with customerId. How should you implement the customer resolver to correctly use resolver chains?
AUse the parent argument to get <code>customerId</code> and fetch customer data from database
BIgnore the parent argument and fetch all customers in the <code>customer</code> resolver
CPass <code>customerId</code> as an argument to the <code>orders</code> resolver
DReturn a static customer object without using parent data
Step-by-Step Solution
Solution:
  1. Step 1: Understand data flow in resolver chains

    The orders resolver returns orders with customerId; the customer resolver uses parent to access customerId.
  2. Step 2: Use parent argument in customer resolver

    The customer resolver should use parent.customerId to fetch the correct customer data from the database.
  3. Final Answer:

    Use the parent argument to get customerId and fetch customer data from database -> Option A
  4. Quick Check:

    Parent passes customerId to customer resolver [OK]
Quick Trick: Use parent.customerId in customer resolver to fetch data [OK]
Common Mistakes:
  • Fetching all customers instead of one
  • Ignoring parent and missing customerId
  • Returning static data ignoring dynamic parent info

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More GraphQL Quizzes