Bird
0
0

How can you optimize resolvers to avoid redundant data fetching when multiple fields require the same data source?

hard📝 Application Q9 of 15
GraphQL - Resolvers
How can you optimize resolvers to avoid redundant data fetching when multiple fields require the same data source?
AWrite separate resolvers for each field that fetch data independently
BUse the parent parameter to pass fetched data down to child resolvers
CAvoid using resolvers and fetch all data in the client
DUse global variables inside resolvers to store data
Step-by-Step Solution
Solution:
  1. Step 1: Recognize data sharing in resolvers

    Parent parameter can carry data fetched by a resolver to child resolvers.
  2. Step 2: Apply this to avoid redundant fetching

    Fetching data once in parent resolver and passing it down avoids repeated calls.
  3. Final Answer:

    Use the parent parameter to pass fetched data down to child resolvers -> Option B
  4. Quick Check:

    Parent passes data to children = A [OK]
Quick Trick: Pass data via parent to child resolvers to optimize [OK]
Common Mistakes:
  • Fetching same data multiple times
  • Avoiding resolvers entirely
  • Using global variables causing side effects

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More GraphQL Quizzes