Bird
0
0

What is wrong with this resolver snippet?

medium📝 Debug Q7 of 15
GraphQL - Resolvers
What is wrong with this resolver snippet?
function resolver(parent, args, context, info) {
  return info.selectionSet.selections;
}
A<code>selections</code> is not an array
B<code>info</code> does not have a direct <code>selectionSet</code> property
CThe resolver is missing the <code>args</code> parameter
DThe return type must be a string
Step-by-Step Solution
Solution:
  1. Step 1: Check info properties

    info itself does not have selectionSet; it is nested inside fieldNodes[0].
  2. Step 2: Correct property access

    Proper access is info.fieldNodes[0].selectionSet.selections.
  3. Final Answer:

    info does not have a direct selectionSet property -> Option B
  4. Quick Check:

    Access selectionSet via info.fieldNodes[0] [OK]
Quick Trick: Use info.fieldNodes[0].selectionSet, not info.selectionSet [OK]
Common Mistakes:
  • Accessing selectionSet directly on info
  • Assuming selections is not an array
  • Ignoring correct resolver signature

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More GraphQL Quizzes