Mutations are operations you use to add, update, and delete data objects. In GraphQL, mutation operations represent the POST, PATCH, PUT, DELETE, and HTTP methods that you’ve defined in your REST API specification.
For example, this RAML specification defines a POST endpoint at /createOrder/{OrderInput}, and the mutation method in the schema is createOrder(input:OrderInput):
| RAML API Specification |
API Schema |
#%RAML 1.0
title: Order API
/createOrder/{OrderInput}:
post:
displayName: Create Order by OrderInput
|
createOrder(input:OrderInput): Order
|
Input types represent the attributes of objects created by mutation operations. Input types are POST, PUT, and DELETE request objects you use to modify information in your unified schema when you run mutations.
For example, you can post to the OrderInput input type using the /createOrder/{OrderInput}: mutation:
createOrder (input: “123”) {
orderId
customerEmail
cutomerID
orderDate
product
status
totalAmount
}