Mutations are the mechanism for editing and transforming data in GraphQL. Eve shows how data is changed in GraphQL by sending a new payload of data to a mutation.
- [Announcer] Throughout these videos so far,…we've focused on how to fetch data.…You might be wondering, how can I make changes to the data.…In GraphQL, data modifications are made with mutations.…Think of this like a PUT or a DELETE request in REST,…but instead of sending new data to a route,…we're going to send data as a payload in the mutation.…GraphQL assumes a mutation has side effects,…and changes the dataset behind the schema.…The API defines which mutations are allowed,…and they, like queries, are in a specific shape.…
For example, let's say I'm running a ski resort,…and I need to make some changes to the status of a ski lift.…It was closed, but now I'm ready to open it.…I'm first going to use a mutation keyword.…This is very similar to an operation name…that we saw with our queries.…So, I can call this operation name anything I'd like to.…Then, the open lift mutation is going to take in…some inputs, so I'll now use the name of the predefined…open lift mutation and this comes directly from the schema.…
In this course, learn how to get started with GraphQL. Eve Porcello walks through the basics of this query language, diving into the data fetching specification, and helping you get up to speed with the syntax and vocabulary of GraphQL. Eve explains how to create basic queries, including how to work with arguments and multiple fields. She also goes into complex techniques for handling data, including working with aliases, fragments, and pagination. Plus, she covers how to edit and transform data with mutations.
- Learning about the origins of GraphQL
- Learning about how GraphQL makes data fetching and updating easier
- Creating basic queries
- Using multiple fields
- Understanding schemas
- Handling data
- Drilling down into nested fields with a query
- Adding variables for argument values
- Creating mutations
- Adding a reaction mutation