# GraphQL

Mechanic tasks have direct inline access to Shopify's GraphQL Admin API. Run queries during task execution to read data, and use GraphQL mutations via the Shopify action to write data — giving you the same level of API access you'd have in a custom app, without the infrastructure.

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

## Reading data with GraphQL

Use the [`shopify` Liquid filter](/platform/liquid/filters.md#shopify) to run a GraphQL query inline during a task run. The result is available immediately.

```liquid
{% capture query %}
  query {
    orders(first: 5, query: "financial_status:paid") {
      nodes {
        id
        name
        totalPriceSet {
          shopMoney {
            amount
          }
        }
      }
    }
  }
{% endcapture %}

{% assign result = query | shopify %}

{% for order in result.data.orders.nodes %}
  {{ order.name }}: {{ order.totalPriceSet.shopMoney.amount }}
{% endfor %}
```

Learn more: [Queries](/platform/graphql/basics/queries.md)

## Writing data with GraphQL

Use the [Shopify action](/core/actions/shopify.md) to run GraphQL mutations. Mutations are queued during the task run and **performed after the task code finishes**.

```liquid
{% action "shopify" %}
  mutation {
    tagsAdd(id: "gid://shopify/Order/1234567890", tags: ["reviewed"]) {
      node {
        id
      }
      userErrors {
        field
        message
      }
    }
  }
{% endaction %}
```

Learn more: [Mutations](/platform/graphql/basics/mutations.md)

## Learn more

* [GraphQL in Liquid](/core/shopify/read/graphql-in-liquid.md) — the complete guide to using GraphQL queries in task code
* [Shopify Admin API GraphiQL explorer](/platform/graphql/basics/shopify-admin-api-graphiql-explorer.md) — test queries interactively
* [Queries](/platform/graphql/basics/queries.md) — reading data with GraphQL
* [Mutations](/platform/graphql/basics/mutations.md) — writing data with GraphQL
* [Pagination](/platform/graphql/basics/pagination.md) — handling paginated results
* [Bulk operations](/platform/graphql/bulk-operations.md) — processing large datasets
* [Converting tasks from Shopify REST to GraphQL](/resources/converting-tasks-from-shopify-rest-to-graphql.md) — migration guide for existing tasks


---

# 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/platform/graphql.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.
