Updating and Deleting Data
Develop mutations for modifying existing data and removing records from your system.
Changing Your Data
So far, you've learned to fetch data with queries and add new data with mutations. But what about modifying or removing existing records?
In this lesson, we'll dive into how GraphQL mutations allow you to update and delete data, making your applications fully dynamic.
GraphQL Update Mutation (SDL)
An update mutation modifies an existing record. It usually requires an identifier (like an ID) to specify which record to change, and then the fields you want to update.
Here's how you might define an updateBook mutation in your GraphQL schema (SDL):
type Mutation {
updateBook(id: ID!, title: String, author: String, year: Int): Book
}
All lessons in this course
- Understanding GraphQL Mutations
- Creating Data with Mutations
- Updating and Deleting Data
- Validating Mutation Input Arguments