Shopify
Run Shopify GraphQL mutations from Mechanic tasks — create orders, update products, manage customers, and more via the Shopify action.
Last updated
Was this helpful?
Was this helpful?
{% capture query %}
mutation DeleteProduct($productId: ID!) {
productDelete(
input: {
id: $productId
}
) {
userErrors {
field
message
}
}
}
{% endcapture %}
{% action "shopify" %}
{
"query": {{ query | json }},
"variables": {
"productId": "gid://shopify/Product/1234567890"
}
}
{% endaction %}{% assign metafield_owner_id = "gid://shopify/Customer/507332001849" %}
{% assign metafield_value = hash %}
{% assign metafield_value["foo"] = "bar" %}
{% capture query %}
mutation MetafieldsSet($metafields: [MetafieldsSetInput!]!) {
metafieldsSet(metafields: $metafields) {
metafields {
key
namespace
value
createdAt
updatedAt
}
userErrors {
field
message
code
}
}
}
{% endcapture %}
{% assign metafield = hash %}
{% assign metafield["ownerId"] = metafield_owner_id %}
{% assign metafield["namespace"] = "demo" %}
{% assign metafield["key"] = "demo" %}
{% assign metafield["type"] = "json" %}
{% assign metafield["value"] = metafield_value | json %}
{% assign metafields = array %}
{% assign metafields = metafields | push: metafield %}
{% assign variables = hash %}
{% assign variables["metafields"] = metafields %}
{% action "shopify" query: query, variables: variables %}