githubEdit

Reading and Writing to Shopify

How Mechanic Shopify automation tasks read and write store data — inline GraphQL queries for reads, and Shopify actions for mutations.

Mechanic tasks have full access to the Shopify Admin API. Tasks can read data inline during execution — running GraphQL queries to fetch additional context beyond the triggering event — and write data via actions that run Shopify GraphQL mutations after the task completes. This gives tasks the same level of API access available to custom apps, without requiring you to build or host app infrastructure.

Reading data

Use the shopify Liquid filter to query Shopify data inline during a task run. This filter accepts a GraphQL query and returns the result immediately.

{% capture query %}
  query {
    product(id: "gid://shopify/Product/1234567890") {
      title
      status
    }
  }
{% endcapture %}

{% assign result = query | shopify %}

{{ result.data.product.title }}

Learn more: Reading data

Writing data

Use the Shopify action to create, update, or delete Shopify resources. Shopify actions are queued during the task run and performed after the task code finishes, so you cannot use the result of a mutation in the same task run that creates it.

Learn more: Writing data

Bulk operations

Use bulk operations when Shopify should process a large read or write asynchronously. Bulk operation queries read large datasets into JSONL results; bulk operation mutations run the same mutation many times using a staged JSONL variables file.

circle-exclamation

Responding to Shopify events

Mechanic can respond to Shopify webhooks (like shopify/orders/create or shopify/products/update) by subscribing tasks to the corresponding event topics.

Learn more: Responding to events

Last updated

Was this helpful?