Bird
0
0

Examine this delete mutation:

medium📝 Debug Q6 of 15
GraphQL - Mutations

Examine this delete mutation:
mutation { deleteProduct(productId: 789) { success } }
Assuming productId is defined as a String in the schema, what is the error?

AThe success field is not valid in the response
BThe mutation name should be deleteProducts instead of deleteProduct
CThe productId value should be a quoted string, not a number
DThe mutation should not have any arguments
Step-by-Step Solution
Solution:
  1. Step 1: Check argument type

    The schema defines productId as a String, so the value must be quoted.
  2. Step 2: Identify error

    Passing 789 without quotes treats it as a number, causing a type mismatch error.
  3. Final Answer:

    The productId value should be a quoted string, not a number -> Option C
  4. Quick Check:

    String arguments require quotes in GraphQL mutations [OK]
Quick Trick: Always quote string arguments in mutations [OK]
Common Mistakes:
  • Passing string IDs without quotes
  • Assuming numeric IDs don't need quotes
  • Misnaming mutation functions

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More GraphQL Quizzes