From the course: GraphQL Essential Training

Unlock this course with a free trial

Join today to access over 25,600 courses taught by industry experts.

Query and mutation types

Query and mutation types - GraphQL Tutorial

From the course: GraphQL Essential Training

Query and mutation types

- [Instructor] Queries and mutations are the basis of running operations in a GraphQL environment. And we'll explore each type. First you have queries, which we already coded one for a product type right here. And if you look into the schema, you can find it right here. The query type is responsible for defining what will return when we make the query. In this case, we are querying a product type and therefore when we run the query, it will return a product or multiple products based on the query. Next, we have mutations, which is basically GraphQL's way of changing data, updating, or creating new data. So let's add a mutation type to our project. So the very first thing that I'm going to do is go back to the index and I'm going to create an in-memory database here. And then we're going to use it, create a class, and then create new products just as an object inside of our application. So let's go ahead and do that first. Okay, so what I'm going to do is just before the const root I'm…

Contents