graphql is one of the most important filters. It calls Shopify GraphQL endpoint to fetch (query) or update (mutation) store data. Any Shopify GraphQL request can be used. Complete documentation of Shopify's GraphQL can be found here:


Let's add a tag to a customer.

First, using Shopify GraphQL reference, we need to find mutation that will allow us to do so. Use capture tag to define our mutation.

{% capture mutation %}
mutation tagsAdd($id: ID!, $tags: [String!]!) {
tagsAdd(id: $id, tags: $tags) {
node {
userErrors {
{% endcapture %}

From the above we see that mutation needs an object id and tag we want to add. Let's use again capture tag to define our mutation variables.

{% capture variables %}
"id": "gid://shopify/Customer/123456",
"tags": "datajet-tag"
{% endcapture %}
{% assign variables = variables | parse %}

Last line converts raw string into JSON object. Now we have everything. Last step is to use graphql filter to execute the query.

{% assign result = mutation | graphql: variables %}