Bird
0
0

Given the resolver function below, what will be the output if args = { id: 10 } and parent = { name: 'Alice' }?

medium📝 query result Q4 of 15
GraphQL - Resolvers
Given the resolver function below, what will be the output if args = { id: 10 } and parent = { name: 'Alice' }?
function resolver(parent, args, context, info) {
  return `${parent.name} has id ${args.id}`;
}
A"Alice has id undefined"
B"Alice has id 10"
C"undefined has id 10"
D"null has id 10"
Step-by-Step Solution
Solution:
  1. Step 1: Substitute parent and args values

    parent.name is 'Alice' and args.id is 10, so the template string becomes 'Alice has id 10'.
  2. Step 2: Evaluate the return statement

    The function returns the combined string with these values.
  3. Final Answer:

    "Alice has id 10" -> Option B
  4. Quick Check:

    Output = "Alice has id 10" [OK]
Quick Trick: Use template strings with parent and args values correctly [OK]
Common Mistakes:
  • Assuming parent or args are undefined
  • Mixing up parent.name and args.id
  • Forgetting to access properties

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More GraphQL Quizzes