Bird
0
0

Given this resolver snippet, what will info.fieldNodes[0].selectionSet.selections.map(f => f.name.value) return if the client queries { user { id name } }?

medium📝 query result Q13 of 15
GraphQL - Resolvers
Given this resolver snippet, what will info.fieldNodes[0].selectionSet.selections.map(f => f.name.value) return if the client queries { user { id name } }?
A["id", "name"]
B["user"]
C["id"]
DAn empty array []
Step-by-Step Solution
Solution:
  1. Step 1: Understand the query structure

    The client requests the fields id and name inside user.
  2. Step 2: Analyze the info.fieldNodes access

    info.fieldNodes[0].selectionSet.selections lists the fields requested inside user, which are id and name.
  3. Final Answer:

    ["id", "name"] -> Option A
  4. Quick Check:

    info.fieldNodes selections = requested fields [OK]
Quick Trick: info.fieldNodes lists requested fields inside current resolver [OK]
Common Mistakes:
  • Returning parent field name instead of subfields
  • Confusing selectionSet with fieldNodes
  • Expecting only one field instead of all requested

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More GraphQL Quizzes