Bird
0
0

How can you update multiple fields in a single mutation and ensure you get back the updated fields plus a timestamp of the update?

hard📝 Application Q9 of 15
GraphQL - Mutations
How can you update multiple fields in a single mutation and ensure you get back the updated fields plus a timestamp of the update?
Amutation { updateItem(id: "3", input: {name: "Item3", price: 20}) { name price updatedAt } }
Bmutation { updateItem(id: "3", name: "Item3", price: 20) { name price updatedAt } }
Cmutation { updateItem(input: {name: "Item3", price: 20}) { name price updatedAt } }
Dmutation { updateItem(id: 3, input: {name: "Item3", price: 20}) { name price updatedAt } }
Step-by-Step Solution
Solution:
  1. Step 1: Confirm correct argument structure

    mutation { updateItem(id: "3", input: {name: "Item3", price: 20}) { name price updatedAt } } correctly uses id as string and input as an object with multiple fields.
  2. Step 2: Verify requested return fields

    mutation { updateItem(id: "3", input: {name: "Item3", price: 20}) { name price updatedAt } } requests name, price, and updatedAt fields, matching the requirement.
  3. Step 3: Check for type correctness

    id is string, price is number inside input, which is valid.
  4. Final Answer:

    mutation { updateItem(id: "3", input: {name: "Item3", price: 20}) { name price updatedAt } } -> Option A
  5. Quick Check:

    Update multiple fields and request timestamp = mutation { updateItem(id: "3", input: {name: "Item3", price: 20}) { name price updatedAt } } [OK]
Quick Trick: Pass multiple fields inside input object, request all needed fields [OK]
Common Mistakes:
  • Passing multiple fields outside input
  • Using numeric id without quotes
  • Not requesting updated timestamp field

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More GraphQL Quizzes