The Shopify action sends requests to the Shopify admin API. It supports both REST and GraphQL requests.
In Mechanic, writing data to Shopify must happen using an action. While the Shopify action is usually the right choice, the HTTP action can also be used for this purpose, by manually configuring authentication headers.
This action has several usage styles, each with a different set of constraints on action options.
GraphQL
This usage style invokes the Shopify GraphQL Admin API. In this style, a single GraphQL query string is supplied as the action options. The action tag has specific support for this action type, allowing this string to be provided as the contents of an action block.
To prepare complex query inputs, use the graphql_arguments Liquid filter.
This usage style invokes the Shopify GraphQL Admin API, and supports combining GraphQL queries with GraphQL variables. This can be useful for re-using queries with multiple inputs, and is critical when dealing with very large pieces of input. Because GraphQL queries (excluding whitespace) are limited in length to 50k characters, GraphQL variables can be used in cases when large inputs (like Base64-encoded images) need to be submitted.
Option
Description
query
Required; a string containing a GraphQL query
variables
Required; a JSON object mapping variable names to values
This usage style invokes Shopify REST Admin API. It accepts an array of option values, containing these elements in order:
Operation Must be one of "get", "post" , "put" , or "delete"
Request path The entire, literal request path to use, including the requested API version â e.g. "/admin/api/2020-01/orders.json"
A JSON object of attributes In general, this means a wrapper object whose key is named after the current resource type, and whose value is the same set of data that would be used in the resourceful style
When switching from resourceful to explicit REST, it's common to forget the outer wrapper object. This wrapper is required by Shopify for all request methods except GET and DELETE; it's handled automatically during resourceful usage, but must be handled manually during explicit usage.