Linear GraphQL API (Polling)
Poll the Linear GraphQL API and transform issues into CDEvents.
- Backfill the history of Linear issues before switching to webhooks.
- Track Linear issues when Linear cannot reach the collector (no inbound endpoint).
| From event | CDEvents |
|---|---|
| issues query, createdAt in the window | ticket.created |
| issues query, completedAt or canceledAt in the window | ticket.closed |
| issues query, updatedAt in the window | ticket.updated |
When to Use
- Historical backfill: ingest the past issues, then switch to the Linear webhook.
- No inbound endpoint: the collector has no public URL that Linear can call.
For real-time ingestion, prefer the webhook. Do not run both at the same time: both emit ticket.created and ticket.closed with different content and timestamps, so each step is stored twice.
How It Works
Linear has no REST API. The http_polling source sends GraphQL POST requests to https://api.linear.app/graphql and follows the pageInfo.endCursor pagination.
A polled issue is a state, not a change. The transformer rebuilds the lifecycle events from the issue timestamps. Each event is emitted only when its timestamp is in the poll window (ts_after included, ts_before excluded). So each lifecycle step is emitted once, even when Linear returns the issue again after later edits.
| Condition | CDEvent Type | Timestamp |
|---|---|---|
createdAt in the window | ticket.created | createdAt |
completedAt or canceledAt in the window | ticket.closed | completedAt / canceledAt |
updatedAt in the window, not equal to the created/closed time | ticket.updated | updatedAt |
Polling is an approximation of the history:
- the content of every event is the issue state at poll time (for example,
ticket.closedshows the labels of the first poll after closing); - several edits between two polls give one
ticket.updated, with the last state.
The ticket fields are the same as for the webhook, so events from both sources are about the same subject.
Configuration
[sources.linear_graphql_api]
enabled = true
transformer_refs = ["linear_graphql_api"]
[sources.linear_graphql_api.extractor]
type = "http_polling"
polling_interval = "10m"
parser = "json"
# Linear API rate limit: 1500 requests / hour per API key
min_request_interval = "3s"
# ts_after = "2025-01-01T00:00:00Z"
driver_vrl = """
query = "query($after: String, $filter: IssueFilter) { issues(first: 100, after: $after, filter: $filter, orderBy: createdAt, includeArchived: true) { nodes { id identifier number title url priorityLabel createdAt updatedAt completedAt canceledAt creator { id } assignee { id } state { id name type } team { id key name } labels { nodes { name } } projectMilestone { name } project { id name } cycle { id number } } pageInfo { hasNextPage endCursor } } }"
# millisecond precision, like Linear's DateTime
ts_format = "%Y-%m-%dT%H:%M:%S%.3fZ"
ts_after = to_string!(.metadata.ts_after)
# ts_after defaults to the beginning of time (a negative year), Linear rejects it: no filter
filter = null
if !starts_with(ts_after, "-") {
filter = { "updatedAt": { "gte": format_timestamp!(parse_timestamp!(ts_after, "%+"), format: ts_format) } }
}
variables = { "after": null, "filter": filter }
cont = true
if .response != null {
if exists(.response.body.errors) {
# GraphQL error with a 2xx status: fail the driver call
abort
}
cont = .response.body.data.issues.pageInfo.hasNextPage == true
variables.after = .response.body.data.issues.pageInfo.endCursor
}
.requests = if cont {
[{
"url": "https://api.linear.app/graphql",
"method": "POST",
"headers": { "content-type": "application/json" },
"body": encode_json({ "query": query, "variables": variables }),
"route": "both",
}]
} else {
[]
}
"""
[sources.linear_graphql_api.extractor.on_status]
# Linear answers GraphQL errors (including rate limit, RATELIMITED) with 400:
# keep the window and retry it on the next poll, instead of the default `skip`
"400" = "hold"
"429" = "hold"
[sources.linear_graphql_api.extractor.headers]
# personal API key: the key itself, no "Bearer " prefix (OAuth token: "Bearer <token>")
authorization = { type = "secret", value = "lin_api_replace_me" }
[remote.transformers-community]
type = "github://cdviz-dev/transformers-community"
[transformers]
linear_graphql_api = { type = "vrl", template_rfile = "transformers-community:///linear_graphql_api/to_v0_5.vrl" }The source comes from the commented example in linear_graphql_api/cdviz-collector.toml, which explains each choice of the query in more detail.
| Setting | Notes |
|---|---|
authorization header | Personal API key as is (lin_api_...), or Bearer <token> for an OAuth token |
ts_after | Set to a past date for a bounded backfill. Unset: the first poll reads all issues |
min_request_interval | Linear allows 1500 requests per hour per API key: 3s stays below it |
on_status | Holds the window on HTTP 400 and 429 (GraphQL errors, rate limit): the next poll retries it |
The query has no upper bound on updatedAt: Linear knows only the last updatedAt of an issue, so an upper bound would drop an issue edited again before the query runs. Pages are sorted by createdAt, which never changes, so an issue edited during paging is not skipped or returned twice.
Limits
- Backfill start: an issue created before the first
ts_aftergets noticket.created, only its later events. Leavets_afterunset on the first run to read the full history. - Team move: Linear gives a moved issue a new identifier, so a new
subject.id. ItscreatedAtis in an older window, so the newsubject.idgets noticket.created, only its later events. - GraphQL errors with a
2xxstatus: the driver fails and the collector logsdriver feedback execution failed, but the window still advances. The remaining pages of that window are not fetched: run a backfill (ts_after,ts_before_limit) for that period.