# 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 }}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.datajet-app.com/liquid/filters/graphql.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
