πŸ†Converting tasks from Shopify REST to GraphQL

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 objects, queries, and mutations.

  2. Review how to use GraphQL in Mechanic Start here and peruse the task library 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 *️

    • product.metafields

    • product.variants *️

    • 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.

  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.

Last updated

Was this helpful?