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

# GraphQL

The GraphQL connector interacts with GraphQL APIs. It provides a single static function to send queries or mutations to an endpoint and retrieve the results. All functions in this class are static and execute without an instance configuration.

### `request`

Sends a query or a mutation to a GraphQL API endpoint.

#### Parameters

<table><thead><tr><th width="150">Input</th><th>Description</th><th width="100">Type</th></tr></thead><tbody><tr><td><code>url</code></td><td>The endpoint URL of the GraphQL API.</td><td>string</td></tr><tr><td><code>document</code></td><td>The GraphQL query or mutation, written in standard GraphQL syntax.</td><td>string</td></tr><tr><td><code>variables</code></td><td>Optional variables required by the document.</td><td>object</td></tr><tr><td><code>headers</code></td><td>Optional request headers as key-value pairs, commonly used for authentication.</td><td>object</td></tr></tbody></table>

{% hint style="info" %}
Right-click the `headers` input and mark it as a secret to mask tokens or credentials.
{% endhint %}

#### Examples

Example 1: Simple query

This queries a list of movies.

```yaml
# url
https://api.example.com/graphql
# document
query {
  movies {
    id
    title
    releaseYear
  }
}
```

Example 2: Query with variables

This fetches a single movie by its ID, passed as a variable.

```yaml
# url
https://api.example.com/graphql
# document
query getMovieById($movieId: ID!) {
  movie(id: $movieId) {
    title
    director {
      name
    }
  }
}
# variables
movieId: "123"
```

Example 3: Mutation

This creates a new movie.

```yaml
# url
https://api.example.com/graphql
# document
mutation createMovie($title: String!, $year: Int!) {
  createMovie(title: $title, releaseYear: $year) {
    id
    title
  }
}
# variables
title: My New Movie
year: 2025
```

Example 4: Query with authentication

This sends an `Authorization` header with a Bearer token.

```yaml
# url
https://api.example.com/graphql
# document
query {
  myPrivateData {
    secretInfo
  }
}
# headers
Authorization: Bearer my-secret-auth-token
```

#### Output

Returns the data payload from the GraphQL API. Throws an error if the request fails or the API returns execution errors.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.heisenware.com/app-builder/build-backend/functions/connectors/graphql.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
