githubEdit

Reading and Writing to Shopify

Mechanic tasks interact with Shopify in two ways: reading data (inline, during a task run) and writing data (via actions, after the task run completes).

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 script finishes, so you cannot use the result of a mutation in the same task run that creates it.

Learn more: Writing data

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?