Home / Companies / Apollo / Blog / Post Details
Content Deep Dive

GraphQL Mutation vs Query – When to use a GraphQL Mutation

Blog post from Apollo

Post Details
Company
Date Published
Author
Khalil Stemmler
Word Count
683
Language
English
Hacker News Points
-
Summary

GraphQL mutations are used to modify server-side data, whereas queries are used to fetch data. Mutations represent the state-changing methods in REST, similar to `DELETE`, `PUT`, and `PATCH`. The structure of a mutation is similar to that of a query, with the main difference being the operation type (`mutation` instead of `query`). Server-side resolvers for mutations involve code that changes state, whereas those for queries typically only fetch data. When determining whether to use a query or a mutation, it's essential to ask yourself if you're fetching data or modifying server-side state.