Root Mutation Type
Explore how to define a root mutation type in a GraphQL schema using Absinthe, including creating mutation fields, modeling input objects, and handling custom scalar types to support data changes.
We'll cover the following...
Defining a root mutation type
We need to define a root mutation type to support mutation operations, just as we did for queries. This will be used as the entry point for GraphQL mutation operations. The mutation fields that we add define the complete list of capabilities available to the API users to modify data. We define the root mutation type by using the mutation macro in our schema file, as shown here:
Both macros—query and mutation are used to define the root object types for their respective GraphQL operations. A mutation root type won’t do us any good unless we define mutation fields.
Adding a mutation field
Now that we have a place to put our mutations, let’s get organized, and develop a plan for menu item creation. Here’s how we expect this feature to work:
- A user will