Query, Mutation, Subscription — Core Operation Types
Fast recall
Quick revision
Core answer
Whether you understand the three operation types at an execution-model level — queries run in parallel on fields, mutations run sequentially, subscriptions hold an open transport (WebSocket/SSE) and emit events.
Running writes from queries ("GET that mutates") because GraphQL lets you — bypassing CSRF, caching, and the audit trail that mutations give you. Or trying to implement subscriptions over plain HTTP without the graphql-transport-ws protocol.
Discuss subscription transport choices (graphql-ws vs graphql-sse), mutation ordering guarantees, per-operation timeouts, and why persisted queries are usually applied only to queries, not mutations.
Interview-ready guide
Interview answer
GraphQL's three operation types differ in execution semantics, not just intent — understanding the difference prevents subtle bugs and incorrect assumptions about ordering and consistency.
Queries — parallel, side-effect free:
- Query fields resolve in parallel because the engine guarantees they are side-effect-free; it may safely run
user,orders, andrecommendationsconcurrently - Writing to a database inside a query resolver violates this contract and risks race conditions — the engine may call it from multiple threads simultaneously
Mutations — serial, with manual rollback:
- Mutation top-level fields execute serially in document order by design — if you batch
createOrderandchargePaymentin one mutation document, they run in written order - Critically, there is no automatic rollback — if
chargePaymentfails, the order is already created; compensating logic is your responsibility - For complex multi-step mutations with rollback requirements, consider saga patterns or service-level transactions behind the resolver
Subscriptions — persistent connection, different infrastructure:
- Subscriptions break the request-response model: the client subscribes once and the server pushes events over WebSocket; in Spring Boot, return a
Fluxfrom@SubscriptionMappingfed by a Reactor sink - The practical consequence most people miss is the transport split: queries and mutations are plain HTTP POST, so existing security filters and load balancers work; subscriptions need WebSocket infrastructure with its own auth flow, reconnection logic, and backpressure handling
I recommend keeping subscriptions on a separate concern from queries and mutations in your architecture — different transport, different auth model, different infrastructure requirements.
Query, Mutation, Subscription — Core Operation Types
Direct Answer
query is for read-only data fetching, mutation is for write operations that change server state, and subscription establishes a long-lived connection for real-time event streams. All three are defined in the GraphQL schema and resolved on the server, but they differ in execution semantics and transport requirements.
Common Mistakes & Pitfalls
Running writes from queries ("GET that mutates") because GraphQL lets you — bypassing CSRF, caching, and the audit trail that mutations give you. Or trying to implement subscriptions over plain HTTP without the graphql-transport-ws protocol.
Check your understanding
Answer these without looking back at the article.
- Why does GraphQL execute mutation fields serially?
- How do you implement WebSocket subscriptions in Spring for GraphQL?
- Can you have multiple fields in a single subscription operation?
Related interview prep categories
1Want a guided curriculum order?
These modules are also sequenced in our flagship backend interview track — open it when you prefer an ordered path instead of browsing by topic.