Bird
0
0

To optimize data fetching in a resolver, how can the info argument be used effectively?

hard📝 Application Q8 of 15
GraphQL - Resolvers
To optimize data fetching in a resolver, how can the info argument be used effectively?
ABy inspecting <code>info.fieldNodes</code> to determine requested fields and fetching only those
BBy using <code>info</code> to access user credentials for authorization
CBy modifying <code>info</code> to add extra fields to the query
DBy ignoring <code>info</code> and fetching all fields unconditionally
Step-by-Step Solution
Solution:
  1. Step 1: Understand optimization goal

    Fetching only requested fields reduces unnecessary data retrieval.
  2. Step 2: Use info.fieldNodes

    This contains the AST nodes representing requested fields, enabling selective fetching.
  3. Step 3: Avoid incorrect uses

    info is not for authorization or modifying queries.
  4. Final Answer:

    By inspecting info.fieldNodes to determine requested fields and fetching only those -> Option A
  5. Quick Check:

    Use info to read requested fields for efficient fetching [OK]
Quick Trick: Use info.fieldNodes to fetch only requested fields [OK]
Common Mistakes:
  • Using info for authorization instead of context
  • Trying to modify info to change queries
  • Fetching all fields regardless of request

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More GraphQL Quizzes