Bird
0
0

Which of the following is the correct syntax for a simple resolver function in GraphQL?

easy📝 Syntax Q12 of 15
GraphQL - Resolvers
Which of the following is the correct syntax for a simple resolver function in GraphQL?
Aconst resolver = (parent; args; context) => data;
Bconst resolver = { parent, args, context } => data;
Cconst resolver = (parent, args, context) => data;
Dconst resolver = (parent args context) => data;
Step-by-Step Solution
Solution:
  1. Step 1: Recall JavaScript arrow function syntax

    Arrow functions use parentheses for parameters separated by commas, e.g., (a, b, c) => result.
  2. Step 2: Check each option's parameter syntax

    const resolver = (parent, args, context) => data; uses commas correctly; A uses semicolons instead of commas; B uses braces instead of parentheses; D misses commas.
  3. Final Answer:

    const resolver = (parent, args, context) => data; -> Option C
  4. Quick Check:

    Arrow function params need commas = C [OK]
Quick Trick: Arrow function params need commas inside parentheses [OK]
Common Mistakes:
  • Using braces {} instead of parentheses () for parameters
  • Separating parameters with semicolons
  • Omitting commas between parameters

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More GraphQL Quizzes