From the course: GraphQL for Enterprise Developers

Unlock this course with a free trial

Join today to access over 24,900 courses taught by industry experts.

Creating a mutation

Creating a mutation

- [Instructor] Let's take a quick look at our data in our cats.json file. We've now added this status called HAPPY or MAD. So this is the status for each one of these pets. So what we want to do here is create our first enumeration type. This is a restricted list of options for a particular field. Let's call this EmotionalStatus. And the potential values here are HAPPY and SAD. Unlike a string, which is just a loose option, that could be any string, this is going to lock down that field a little bit more carefully. So let's go ahead and add that to the Cat. We're going to say status is EmotionalStatus, and we'll make that required with the exclamation mark or non-nullable. From here, what I can do, I want to create my first mutation type. A Query is going to get data. A Mutation is going to change data. So all of those operations, like creating something, updating something, editing something, deleting something, all of those things can be relegated to this Mutation type. So we're…

Contents