Root Mutation Type
Learn root mutation types and how we add mutation fields in GraphQL.
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:
Press + to interact
mutation do#<<mutation fields will go here>>end
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 ...