> For the complete documentation index, see [llms.txt](https://v2.dataos.info/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://v2.dataos.info/references/interfaces/apis/data-product-apis/api-reference/graphql.md).

# GraphQL

Technical contract for GraphQL schema access and execution.

Query the semantic layer with GraphQL and receive GraphQL-shaped results inline. Unlike the other [Query](https://v2.dataos.info/references/interfaces/apis/data-product-apis/api-reference/query.md) endpoints, this one normally responds synchronously.

For a full request/response walkthrough, including variables and response validation, see the [Semantic GraphQL recipe](https://v2.dataos.info/consume/recipes/query-semantic-model-with-graphql) in Consume.

***

## Execute GraphQL query

**API endpoint:** POST /api/v1/query/semantic/graphql

**Description:** Query the semantic layer using GraphQL and receive results inline. Use it for GraphQL-native clients that want a nested response shaped by the selection set.

GraphQL normally returns the completed response synchronously. Do not start a separate statement polling workflow unless the response indicates execution is still in progress.

**Key query params:**

| Parameter                 | Default | Description                                       |
| ------------------------- | ------- | ------------------------------------------------- |
| `retry_on_recent_failure` | `false` | Retry even if an identical query failed recently. |

**Request body:**

```json
{
  "query": "query { table(limit: 10) { orders { store_region total_revenue } } }"
}
```

**cURL:**

```bash
curl -s -X POST https://$BASE_URL/api/v1/query/semantic/graphql \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "query { table(limit: 10) { orders { store_region total_revenue } } }"
  }'
```

**Example success response:**

```json
{
  "data": {
    "table": [
      {
        "orders": {
          "store_region": "north",
          "total_revenue": 12500.5
        }
      }
    ]
  },
  "extensions": {
    "statement_id": "stmt_abc123",
    "strategy": "REUSE_RESULT",
    "status": "SUCCESS",
    "is_stale": false
  }
}
```

**Returns:** `200 OK` returns GraphQL `data` and execution metadata. GraphQL validation or resolver failures can also use HTTP `200 OK` with a top-level `errors` array, so clients must inspect the body. `202 Accepted` with `Retry-After` means processing continues; safely retry the same query.

**Errors:**

* **503 Service Unavailable**: An upstream connection failed.
* **504 Gateway Timeout**: The upstream GraphQL service did not respond within the configured timeout.

***

## 504 Timeout and Resubmit

A `504` does not abort the underlying warehouse query; it continues running in the background regardless of the timeout. Resubmitting the same GraphQL query after a back-off is safe:

* If the original warehouse query is still running, it is deduplicated (`AWAIT_PRIMARY`). The resubmit waits for the original result; the warehouse query does not execute twice.
* If it already completed, the prior result is served immediately (`REUSE_RESULT`).

No statement ID is needed to resubmit. If timeouts recur despite retries, simplify the query (fewer fields, narrower time ranges) or contact the Data Product owner.


---

# 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://v2.dataos.info/references/interfaces/apis/data-product-apis/api-reference/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.
