> For the complete documentation index, see [llms.txt](https://docs.datajet-app.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.datajet-app.com/liquid/filters/graphql.md).

# graphql

{% hint style="info" %}
Deprecated. Use [graphql](/liquid/tags/graphql.md) tag instead.
{% endhint %}

`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:

{% embed url="<https://shopify.dev/docs/admin-api/graphql/reference>" %}

#### Example

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.

```javascript
{% capture mutation %} 
  mutation tagsAdd($id: ID!, $tags: [String!]!) {
    tagsAdd(id: $id, tags: $tags) {
      node {
        id
      }
      userErrors {
        field
        message
      }
    }
  }
{% 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.

```javascript
{% json variables %}
  {
    "id": "gid://shopify/Customer/123456",
    "tags": "datajet-tag"
  }
{% endjson %}
```

Before we execute above GraphQL mutation we need to tell compiler what to expect in order to evaluate required permission for executing this task. See more [here](/scripts/creating-a-task.md).

```
{%- comment -%} Feed compiler with dummy values to evaluate permissions required.{%- endcomment -%}
{% if mode.compiler %}
  {% json dummy_mutation_variables %}
    {
      "id": "gid://shopify/Customer/123456",
      "tags": "test"
    }
  {% endjson %}
  {% assign result = mutation | graphql: dummy_mutation_variables %}
{% endif %}
{%- comment -%}END REST and GraphQL definitions{%- endcomment -%}
```

\
Now we have everything. Last step is to use `graphql` filter to execute the query.

```javascript
{% assign result = mutation | graphql: variables %}
{{result | log }}
```
