> ## Documentation Index
> Fetch the complete documentation index at: https://docs.fastgen.com/llms.txt
> Use this file to discover all available pages before exploring further.

# GraphQL Request

**Interact with any GraphQL API**.

<img src="https://mintcdn.com/organa/x4VcIWGQE6pfuZkY/images/graphql_header.webp?fit=max&auto=format&n=x4VcIWGQE6pfuZkY&q=85&s=23ce38a8f45570b77ddde374aa78c904" alt="graphql-request-header" width="3240" height="1808" data-path="images/graphql_header.webp" />

The GraphQL Request Action allows you to seamlessly interact with any GraphQL API by sending queries or mutations, including headers and authentication information. This action simplifies the process of making GraphQL requests and handling responses within your flows.

### Usage

Within the Action, you can specify any GraphQL endpoint you want to fetch data from.

Inside the `Configure Query` modal, you can specify your GraphQL query or mutation, as well as define any variable you need to use inside your request.
Check out the official [GraphQL Documentation](https://graphql.org/learn/queries/) if you need some more information on how to write a GraphQL query.

Additionally, you can also set your authentication or any request headers that you need.

#### Using Variables

Variables within the GraphQL query work by using the `Variables` drawer at the bottom of the `Edit Request` modal. As an example lets imagine that we have a route for fetching Rick & Morty characters via the [https://rickandmortyapi.com](https://rickandmortyapi.com) GraphQL API and we filter these results by the name that we pass in via an query parameter to the fastgen route.

We would then enter the `https://rickandmortyapi.com/graphql` as the url of the GraphQL action and then start of by defining a mapping to make the `name` query parameter accessible within the query syntax.

```json Variables theme={null}
{
  "name": "{{$query.name}}"
}
```

Now that we have defined where the variable is coming from, we can specify the Query as

```json Query theme={null}
query Query($name: String) {
  characters(filter: { name: $name }) {
    info { count }
    results { name }
  }
}
```

The first line of the query defines that we are gonna in a variable called `name` of type string for which we just created a mapping. On the next line we then use the variable to filter all records using that name.

If we now call our fastgen route and pass in the name in the query either by specifying it in the url like `/rickandmorty?name=rick` or by specifying it under `URL Parameters > Query` in the request modal of the fastgen debug mode, we can see all filtered records being returned.

### Output

```json theme={null}
{
    "Status": 200,
    "Body": "" // String or already parsed if response content-type is 'application/json'
    "Header": { // Response header
      "Content-Type": "application/json",
      "...": "..."
    }
}
```
