Mutation Root
GraphQL mutations all begin with the mutation keyword:
mutation($accountNumber: ID!, $newBalance: Int!) {
# ^^^^ here
setAccountBalance(accountNumber: $accountNumber, newBalance: $newBalance) {
# ...
}
}
Operations that begin with mutation get special treatment by the GraphQL runtime: root fields are guaranteed to be executed sequentially. This way, the effect of a series of mutations is predictable.
Mutations are executed by a specific GraphQL object, Mutation. This object is defined like any other GraphQL object:
class Types::Mutation < Types::BaseObject # ... end
Then, it must be attached to your schema with the mutation(...) configuration:
class Schema < GraphQL::Schema # ... mutation(Types::Mutation) end
Now, whenever an incoming request uses the mutation keyword, it will go to Mutation.
See Mutation Classes for some helpers to define mutation fields.