Bird
0
0

Which of the following is the correct syntax for an update mutation in GraphQL?

easy📝 Syntax Q12 of 15
GraphQL - Mutations
Which of the following is the correct syntax for an update mutation in GraphQL?
Amutation { updateUser(id: "123", input: {name: "Alice"}) { id name } }
Bmutation { createUser(id: "123", input: {name: "Alice"}) { id name } }
Cquery { updateUser(id: "123", input: {name: "Alice"}) { id name } }
Dmutation { deleteUser(id: "123") { id name } }
Step-by-Step Solution
Solution:
  1. Step 1: Identify the mutation keyword and operation

    Update mutations use the mutation keyword and specify the update operation with an ID and input object.
  2. Step 2: Check the options for correct mutation syntax

    mutation { updateUser(id: "123", input: {name: "Alice"}) { id name } } uses mutation with updateUser and input fields correctly; others use wrong operation or query keyword.
  3. Final Answer:

    mutation { updateUser(id: "123", input: {name: "Alice"}) { id name } } -> Option A
  4. Quick Check:

    Update mutation syntax = mutation + update operation + input [OK]
Quick Trick: Update mutations use 'mutation' keyword with update operation [OK]
Common Mistakes:
  • Using 'query' instead of 'mutation'
  • Using create or delete operation instead of update
  • Missing input object for new values

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More GraphQL Quizzes