# Converting tasks from Shopify REST to GraphQL

{% hint style="danger" %}
**Important Notice**

Shopify has deprecated the REST Admin API that Mechanic's REST objects depend on. The product and variant endpoints were removed on Feb 1, 2025, and Shopify is phasing out the remaining REST endpoints over time. Read more [here](https://shopify.dev/docs/apps/build/graphql/migrate/new-product-model#whats-changing) and [here](https://shopify.dev/docs/apps/build/graphql/migrate).

Use [GraphQL](/core/actions/shopify.md#graphql) going forward. The [product](/platform/liquid/objects/shopify/product.md) and [variant](/platform/liquid/objects/shopify/variant.md) objects no longer work. The remaining REST objects will follow as Shopify continues the migration.
{% endhint %}

These conversion tutorials will be be based on products, variants, and associated resources, but the methodologies are applicable to other type of REST resources as well.

#### At a high-level, converting Mechanic tasks from Shopify REST lookups to GraphQL queries involves:

1. **Understanding the Shopify GraphQL schema**\
   Familiarize yourself with the [Shopify GraphQL Admin API](https://shopify.dev/docs/api/admin-graphql) objects, queries, and mutations.
2. **Review how to use GraphQL in Mechanic**\
   Start [here](/core/shopify/read/graphql-in-liquid.md) and peruse the [task library](/resources/task-library.md) to see examples of GraphQL usage in tasks.
3. **Identify REST usage within a task**\
   Broadly, any usage where **one Liquid REST object** is used to reference another Liquid REST object with dot notation. This does not include fields on the original REST-like webhook resource (e.g. `product.title`).\
   \
   For the product and variant resource deprecations specifically, this includes:
   * `shop.products`
   * `shop.variants`
   * `collection.products`
   * `inventory_item.variant`
   * `inventory_level.variant`
   * `line_item.product`
   * `line_item.variant`
   * `product.collections`
   * `product.images` :asterisk\_symbol:
   * `product.metafields`
   * `product.variants` :asterisk\_symbol:
   * `variant.inventory_item`
   * `variant.inventory_levels`
   * `variant.metafields`
   * `variant.product`
4. **Field mapping**: Identify the objects, fields, and nested structures needed in GraphQL based on the existing REST usage within a task. Build and validate queries using [Shopify's GraphiQL Explorer](/platform/graphql/basics/shopify-admin-api-graphiql-explorer.md).
5. **Update Mechanic task code** : Replace the relevant REST calls with Mechanic-flavored Liquid GraphQL query and result objects (see the tutorials following this page for examples).
6. **Testing**: Trigger the updated task to make sure it returns the expected results and/or takes the expected actions.

{% hint style="warning" %}
The product webhook does include an array of images and variants in the product JSON which will still be accessible via dot notation. Note that these are not the same as the previously available Mechanic REST lookups for those resources.

The images and variants data arrays should be used with caution once Shopify releases [support for 2 thousand variants per product](https://shopify.dev/docs/apps/build/graphql/migrate/new-product-model#whats-changing), in conjunction with the product and variant REST endpoint deprecations. The product webhook will only include full detail for the first 100 variants. It is not yet clear what Shopify will do with images in the product webhook.
{% endhint %}


---

# 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/resources/converting-tasks-from-shopify-rest-to-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.
