GraphQL mutations create, update, or delete objects in the Shopify GraphQL admin API. A mutation has a name, takes input data, and specifies fields to return in the response.
{% hint style="info" %} This page discusses the general concept of a GraphQL mutation. For more detail on how this applies to Mechanic and the Shopify API, see Actions / Shopify. {% endhint %}
{% tabs %} {% tab title="GraphQL mutation" %}
mutation {
productCreate(input: {title: "Red Ball", productType: "Toy", vendor: "Toys"}) {
product {
id
}
}
}
{% endtab %}
{% tab title="Response" %}
{
"data": {
"productCreate": {
"product": {
"id": "gid://shopify/Product/13588"
}
}
}
}
{% endtab %} {% endtabs %}
{% tabs %} {% tab title="GraphQL mutation" %}
mutation {
productUpdate(input: {id: "gid://shopify/Product/13588", productType: "Ball"}) {
product {
id
type
}
}
}
{% endtab %}
{% tab title="Response" %}
{
"data": {
"productCreate": {
"product": {
"id": "gid://shopify/Product/13588"
"productType" : "Ball"
}
}
}
}
{% endtab %} {% endtabs %}
{% hint style="success" %} https://shopify.dev/concepts/graphql/mutations {% endhint %}
{% hint style="success" %} https://www.shopify.com/partners/blog/getting-started-with-graphql {% endhint %}
{% hint style="success" %} https://graphql.org/learn/queries/ {% endhint %}