Skip to main content

Mutations

Important

This part of the GraphQL API is currently in Early Availability status. For more information, see GraphQL API policy.

Mutations modify and return data. As with queries, you must specify which fields you want to be returned, but you must also use arguments to provide the data that you want to create, update, or delete.

There are three essential parts of a mutation:

  • The mutation name, which identifies the type of action that you want to perform. For example, use the productCreate mutation to add a product to your marketplace's staging catalog.

  • An input object, which includes the various fields and field values that you want to modify. For a new product, typical information consists of the product name, type, and so on.

  • A payload object, which includes the fields that you want to see in the response.

Mutations are requests to modify data in some way, similar to POST, PATCH, PUT, and DELETE requests in a REST API.

Mutations are formed in this way:

mutation{
mutationName(
inputObject:{
inputField1
inputField2
inputFieldN
}
)
{
payload{
returnField1
returnField2
returnFieldN
}
}
}

Example

The following request creates a product in the staging catalog. It uses the productCreate mutation, the product input object, and all of the required input fields. It also requests a product response payload with the name, id, and vendorId return fields.

mutation{
productCreate(
product:{
type:WEB_APP,
name:"My product",
addon:false,
referable:false,
allowMultiplePurchases:true,
usageType:MULTI_USER
}
)
{
product{
name
id
vendorId
}
}
}

The response to this example mutation would look like this:

{
"data": {
"productCreate": {
"product": {
"name": "My product",
"id": "72a3a80e-8b5f-4a88-b2a4-51b8ed07d5b5",
"vendorId": "ce0a5582-2601-4080-b969-99f949492982"
}
}
}
}

Was this page helpful?