← GraphQL learning path
GraphQL · Module 4 of 10

Mutations

Create, update and delete data with mutations.

📖 Key ideas

  1. mutation { createPost(input: { title: "Hi" }) { id title } }.
  2. Mutations return data so the client can update its UI.
  3. Use input types for arguments.
  4. Name mutations as verbs: createUser, updatePost, deleteComment.
  5. Return errors in a predictable way.
💡 Real-life example: A mutation is filling a form at the counter and getting a receipt with the new details.
MutationWrite operation
Input typeTyped argument object
PayloadData returned after a mutation
Optimistic updateUpdate UI before server confirms