Mutations for modifying data in GraphQL
In this recipe, we will learn how to modify data using GraphQL. GraphQL mutations are analogous to POST, PUT, and PATCH methods in REST. GraphQL mutations allow us to perform data modifications and at the same time return the modified data. In GraphQL, mutations are operations that cause side effects on the server and return the modified data, allowing clients to specify exactly what data they need in the response.
We will also use type extensions to organize our mutations. In GraphQL schemas, there’s a single root mutation type. We can define multiple mutation fields within this type. In this recipe, we’ll use type extensions to organize our mutations into separate classes for better code maintainability.
Getting ready
- The startup project can be cloned here: https://github.com/PacktPublishing/ASP.NET-9-Web-API-Cookbook/tree/main/start/chapter08/Mutations
How to do it…
- We already have Hot Chocolate...