Chapter 5
Making a Change with Mutations

It’s easy to focus on GraphQL’s data-fetching capabilities; the flexibility it gives clients when crafting queries is certainly its most striking feature, but it’s not a read-only data platform. GraphQL also supports mutations, which allow users of the API to modify server-side data.

If you’re familiar with REST APIs, you can think of GraphQL mutations as roughly analogous to POST, PUT, and DELETE operations. Unlike REST, however, the responses from GraphQL mutations can be tailored, just as with GraphQL query operations.

In this chapter, we’re going to explore how GraphQL mutations can be used by adding menu-item management features to our PlateSlate application. You’ll learn how to add a root mutation type and define fields, get acquainted with modeling new records with input objects, and uncover important strategies that you can use to return error information if something goes wrong.

Let’s jump in by building our first mutation, which will let users create menu items using the PlateSlate API.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.12.50