# Reading and Writing to Shopify

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](/platform/liquid/filters.md#shopify) to query Shopify data inline during a task run. This filter accepts a GraphQL query and returns the result immediately.

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

{% assign result = query | shopify %}

{{ result.data.product.title }}
```

Learn more: [Reading data](/core/shopify/read.md)

## Writing data

Use the [Shopify action](/core/actions/shopify.md) 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.

```liquid
{% action "shopify" %}
  mutation {
    productUpdate(input: { id: "gid://shopify/Product/1234567890", title: "New Title" }) {
      product {
        title
      }
      userErrors {
        field
        message
      }
    }
  }
{% endaction %}
```

Learn more: [Writing data](/core/shopify/write.md)

## Bulk operations

Use [bulk operations](/core/shopify/bulk-operations.md) 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.

{% hint style="warning" %}
Shopify REST is deprecated in Mechanic. Use the GraphQL Admin API for all new tasks. See [Converting tasks from Shopify REST to GraphQL](/resources/converting-tasks-from-shopify-rest-to-graphql.md) for migration guidance.
{% endhint %}

## 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](/core/events/topics.md).

Learn more: [Responding to events](/core/shopify/events.md)

## Related

* [API rate limit](/core/shopify/api-rate-limit.md) — how Mechanic manages Shopify's rate limits
* [API versions](/core/shopify/api-versions.md) — how tasks select a Shopify API version
* [Bulk operations](/core/shopify/bulk-operations.md) — asynchronous Shopify reads and writes
* [Shopify admin action links](/core/shopify/admin-action-links.md)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://learn.mechanic.dev/core/shopify.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
