© The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature 2023
N. BiswasPractical GraphQLhttps://doi.org/10.1007/978-1-4842-9621-9_3

3. Mutations

Nabendu Biswas1  
(1)
Bhopal, India
 

In this chapter, you will learn about mutations. With mutations, you basically create, update, and delete your data. It is like the POST, PUT, and DELETE operations of the RESTful API.

Creating Data

You need to add a mutation in the schema.js file first. Here, we will create a new type of mutation. Inside it we will create our first mutation of addGenre, which will take input and also return the genre. See Listing 3-1.
exports.typeDefs = gql`
    type Query {
        courses(filter: CoursesFilter): [Course!]!
        course(id: ID!): Course ...

Get Practical GraphQL: Learning Full-Stack GraphQL Development with Projects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.