- Input Objects
Mutation type in a GraphQL schema defines all the write operations that can change data.
It is analogous to performing HTTP verbs such as
Mutations can take arguments as input similar to the body of a
POST request in REST. Like GraphQL queries, mutations can also return fields. This can be useful for fetching the new state of an object after an update.
The return type of mutations in the Storefront API always includes a
userErrors field. This is a list of errors that occurred during the mutation and each error includes a
field. These errors make it easy to display information to the user such as validation errors.
We strongly recommend to always include
userErrors in your mutation query. If your mutation is returning
null, it's likely that there are errors which you won't see without it.
Here's an example of a mutation and its errors:
A successful mutation without errors would return the following: