Bird
0
0

Given the mutation below, what will be the output if the user with id 3 exists?

medium📝 query result Q4 of 15
GraphQL - Mutations
Given the mutation below, what will be the output if the user with id 3 exists?
mutation { updateUser(id: 3, name: "Anna") { id name } }
A{ "data": { "updateUser": null } }
B{ "data": { "updateUser": { "id": 3, "name": "Anna" } } }
CSyntax error: missing brackets
DError: user id 3 not found
Step-by-Step Solution
Solution:
  1. Step 1: Understand mutation behavior

    If the user with id 3 exists, the mutation updates the name to "Anna" and returns the updated user data.
  2. Step 2: Analyze the options

    { "data": { "updateUser": { "id": 3, "name": "Anna" } } } shows the updated user data correctly; others show errors or null.
  3. Final Answer:

    { "data": { "updateUser": { "id": 3, "name": "Anna" } } } -> Option B
  4. Quick Check:

    Mutation updates and returns data [OK]
Quick Trick: Mutation returns updated data if item exists [OK]
Common Mistakes:
  • Assuming mutation returns null on success
  • Thinking mutation causes syntax error here
  • Believing mutation fails if user exists

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More GraphQL Quizzes