> 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/concepts/foundations/activation/apis/getting-started/querying-data-products/graphql.md).

# GraphQL

GraphQL is useful when you want schema discovery, typed field selection, and a query shape that fits frontend clients. It targets the same semantic layer as REST and Semantic SQL.

**Endpoint:** `POST /api/v1/query/semantic/graphql`

**Headers:** `Authorization: Bearer $TOKEN`, `X-User: <user-id>`

### Response lifecycle

GraphQL returns rows in the same response when the query finishes within \~55 seconds (`200` with `data`). If it is still running, you get `202` with `Retry-After` and `extensions.statementId` — retry the GraphQL request or poll the statement API in [Statement lifecycle](/concepts/foundations/activation/apis/getting-started/querying-data-products/statement-lifecycle.md).

| Outcome                        | HTTP                                                  | What you do                                                                                                                                                          |
| ------------------------------ | ----------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Query finishes in time         | `200` with `data`                                     | Use `data` — no polling                                                                                                                                              |
| Query still running at timeout | `202` with `Retry-After` and `extensions.statementId` | Retry after the wait, or poll `GET /api/v1/query/statement/{id}`                                                                                                     |
| Identical query retried        | `202` (may reuse result)                              | Same deduplication as async submits — see [Statement lifecycle](/concepts/foundations/activation/apis/getting-started/querying-data-products/statement-lifecycle.md) |

For queries that routinely run longer than \~55 seconds, use [REST](/concepts/foundations/activation/apis/getting-started/querying-data-products/rest.md) or [Semantic SQL](/concepts/foundations/activation/apis/getting-started/querying-data-products/semantic-sql.md).

On timeout the response is `HTTP 202` with `Retry-After: 30` and a body like:

```json
{
  "data": null,
  "extensions": {
    "status": "IN_PROGRESS",
    "statementId": "a3f8c1d2-...",
    "_links": {
      "self": { "href": "/api/v1/query/statement/a3f8c1d2-..." },
      "result": { "href": "/api/v1/query/statement/a3f8c1d2-.../result" }
    }
  }
}
```

### Basic query

GraphQL:

```graphql
query {
  table(limit: 10) {
    users {
      plan_type
      active_users
    }
  }
}
```

REST equivalent:

```json
{
  "measures": ["users.active_users"],
  "dimensions": ["users.plan_type"],
  "limit": 10
}
```

### Time granularity

```graphql
query {
  table {
    store_revenue {
      product_category
      measure
      ts {
        day
      }
    }
  }
}
```

REST equivalent:

```json
{
  "dimensions": ["store_revenue.product_category", "store_revenue.ts.day"],
  "measures": ["store_revenue.measure"]
}
```

### Filters and ordering

```graphql
query {
  table(
    limit: 100
    timezone: "America/Los_Angeles"
  ) {
    subscriptions(
      orderBy: { plan_type: asc, total_arr: desc }
      where: { status: { equals: "active" } }
    ) {
      plan_type
      total_arr
    }
  }
}
```

GraphQL filter differences from REST JSON:

* Numbers are JSON numbers, not strings.
* Null checks use `{ set: false }` instead of `notSet`.
* `in` and `notIn` are supported on string, number, and time fields.
* Time fields have no `onTheDate`. Filter one calendar day with `inDateRange` and the same start and end date, or use `beforeDate`, `afterDate`, `beforeOrOnDate`, or `afterOrOnDate`.
* `@include(if: $var)` and `@skip(if: $var)` work on fields.

Single-day time filter:

```graphql
users(
  where: {
    signup_date: {
      inDateRange: ["2025-01-15", "2025-01-15"]
    }
  }
) {
  total_users
}
```

GraphQL has no `segments[]`. Express segment logic in `where`:

```graphql
query {
  table {
    users(
      where: {
        status: { equals: "active" }
        plan_type: { equals: "free" }
      }
    ) {
      total_users
    }
  }
}
```

### Multiple models

```graphql
query {
  table(limit: 5) {
    users {
      plan_type
    }
    usage_events {
      total_events
    }
  }
}
```

Cross-model rules are covered in [Cross-model queries](/concepts/foundations/activation/apis/getting-started/querying-data-products/cross-model-queries.md). `joinHints` are not available in GraphQL.

### Introspection

```graphql
{
  __schema {
    types {
      name
      kind
      fields {
        name
        type { name }
      }
    }
  }
}
```

Capability gaps vs REST are covered in [GraphQL vs REST](/concepts/foundations/activation/apis/getting-started/querying-data-products/graphql-vs-rest.md).


---

# 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 dynamically by asking a question.

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

```
GET https://v2.dataos.info/concepts/foundations/activation/apis/getting-started/querying-data-products/graphql.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
