hen 0.21.0

Run protocol-aware API request collections from the command line or through MCP.
Documentation
---
sidebar_position: 5
title: GraphQL
description: Send GraphQL-over-HTTP requests with variables, an operation name, and GraphQL selectors.
---

Source file:
[examples/graphql_protocol.hen](https://gitlab.com/ben_goodman/apps/hen/-/blob/main/examples/graphql_protocol.hen)

## What It Demonstrates

- `protocol = graphql`
- `operation` and `variables` directives
- `~~~graphql` request bodies
- `graphql.data...` selectors

## Key Pattern

```hen
protocol = graphql
POST {{ GQL_ORIGIN }}
operation = GetUser
variables = {"getUserId":"abc1234"}

~~~graphql
query GetUser($getUserId: String) {
  getUser(id: $getUserId) {
    id
    name
  }
}
~~~
```

## Run It

```bash
hen verify ./examples/graphql_protocol.hen
hen run ./examples/graphql_protocol.hen 0 --non-interactive
```

## What To Notice

- GraphQL still executes over HTTP, so status, headers, and ordinary body access remain available.
- Successful responses may omit `errors` entirely, so `graphql.data...` is the most stable selector
  for positive assertions.

Related reference: [Protocols](../reference/protocols.md)