Bird
0
0

Identify the error in the following resolver function signature:

medium📝 Debug Q6 of 15
GraphQL - Resolvers
Identify the error in the following resolver function signature:
const resolver = (args, parent, context) => { return parent.id; }
AThe function should not return parent.id
BMissing the info argument
CArguments order is incorrect; parent should come before args
DArrow function cannot be used for resolvers
Step-by-Step Solution
Solution:
  1. Step 1: Recall correct resolver argument order

    The correct order is (parent, args, context, info). Here, args comes before parent, which is wrong.
  2. Step 2: Check other options

    Info argument is optional, arrow functions are valid, and returning parent.id is valid if parent exists.
  3. Final Answer:

    Arguments order is incorrect; parent should come before args -> Option C
  4. Quick Check:

    Correct order = parent, args, context [OK]
Quick Trick: Always put parent first, then args in resolver signature [OK]
Common Mistakes:
  • Swapping parent and args order
  • Thinking info is mandatory
  • Believing arrow functions are invalid

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More GraphQL Quizzes