GraphQL variable support for the "shopify" action

The "shopify" action has a new, optional syntax that supports GraphQL variables. By providing a JSON hash of options, consisting of a "query" key and a "variables" key, you may now separate your inputs from the query itself, allowing both for query re-use and for variables in excess of Shopify's 50k-character limit for query strings.

This syntax is available in block form:

{% capture query %}
  mutation DeleteProduct($productId: ID!) {
    productDelete(
      input: {
        id: $productId
      }
    ) {
      userErrors {
        field
        message
      }
    }
  }
{% endcapture %}

{% action "shopify" %}
  {
    "query": {{ query | json }},
    "variables": {
      "productId": {{ product.admin_graphql_id | json }}
    }
  }
{% endaction %}

… and in tag form:

{% assign variables = hash %}
{% assign variables["productId"] = product.admin_graphql_api_id %}

{% action "shopify", query: query, variables: variables %}

This change does not impact existing uses of the "shopify" action.

Read more