⬡ GraphQL Beginner

What is the difference between a query and a mutation in terms of execution?

Answer

The key execution difference is ordering: query fields resolve in parallel (by default), while mutation fields resolve serially (one after another in order). This is intentional — mutations may have side effects that depend on each other, and sequential execution ensures predictability. Example: sending two mutations mutation { deleteUser(id: "1") updateUser(id: "1", name: "X") } executes delete first, then update. If both were parallel, the order would be undefined. Queries are assumed to be pure (no side effects), so the executor can fetch all fields concurrently for better performance. In practice, individual resolvers within a single mutation are still executed — it's only the top-level mutation fields that are sequential. Both return data in the response following the same structure.