Bird
0
0

You wrote this resolver: function resolver(parent, args, context) { return info.fieldNodes; }. Why does this cause an error?

medium📝 Debug Q14 of 15
GraphQL - Resolvers
You wrote this resolver: function resolver(parent, args, context) { return info.fieldNodes; }. Why does this cause an error?
AYou cannot access <code>fieldNodes</code> inside resolvers.
BThe resolver is missing the <code>info</code> argument in its parameters.
CThe <code>info</code> argument must be the first parameter.
DResolvers cannot return objects like <code>fieldNodes</code>.
Step-by-Step Solution
Solution:
  1. Step 1: Check resolver parameters

    The resolver only has three parameters: parent, args, context. It lacks the fourth parameter info.
  2. Step 2: Understand usage of info

    Since info is not declared, trying to use it causes a reference error.
  3. Final Answer:

    The resolver is missing the info argument in its parameters. -> Option B
  4. Quick Check:

    Missing info param = error [OK]
Quick Trick: Always include info as fourth parameter to use it [OK]
Common Mistakes:
  • Forgetting to add info parameter
  • Assuming info is global or in context
  • Misordering resolver parameters

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More GraphQL Quizzes