Transport for Linear's GraphQL API.
Per-call credentials. Every API-calling function in this package
takes an optional trailing opts Map, resolved by resolve: opts
first, then the linear.api.key context variable, then the defaults.
Nothing from opts is written to ctx, so one run can act for many
workspaces and parallel flows don't share credentials. An api-key
present but blank or null is an error, never a fallback to context.
api-key: the personal API key (lin_api_...) or OAuth token (lin_oauth_...) for this callbase-url: another GraphQL endpoint, such as a proxy. It needs anapi-keyin the sameopts:linear.api.keyis never sent to a per-call URL.
Context Vars
linear.api.key
Functions
auth-header
fn (key: Str): Str
Build the Authorization header value: personal API keys (lin_api_...) go raw; OAuth tokens (lin_oauth_...) get the Bearer prefix, per Linear's docs.
blank-credential
fn (opts: Map, names: Vec): Str?
The first of names that opts has but with a blank or null value, else null. Such a key is an error, never a fallback to context: a tenant whose key is missing must not run on the project's credentials.
build-request
fn (query: Str, variables: Map, resolved: Map): ::hot::http/HttpRequest
The outgoing HttpRequest from resolved settings (see resolve). Pure; exposed for testing.
graphql
fn (query: Str): Any
fn (query: Str, variables: Map): Any
fn (query: Str, variables: Map, api-key: Str): Any
fn (query: Str, variables: Map, opts: Map): Any
Execute a GraphQL query or mutation against Linear. Returns the
data object, or an Err carrying {errors, data} for GraphQL errors
and {status, body} for transport errors.
Example
me ::linear::api/graphql("query { viewer { id name email } }", {})
me.viewer.name
// Per-call credentials
other ::linear::api/graphql("query { viewer { id } }", {}, {api-key: "lin_api_tenant_b"})
non-blank
fn (value: Any): Str?
parse-graphql-response
fn (body: Map): Any
Unwrap a GraphQL response body: returns data when there are no errors, otherwise an Err carrying {errors, data}. Exposed for testing; graphql applies it.
resolve
fn (opts: Map): Map
Credentials and settings for one call (see resolve-from). opts
values are never written to ctx.
A credential from opts is masked in the run's call records.
Example
::linear::api/resolve({api-key: "lin_api_tenant_b"}).base-url // "https://api.linear.app/graphql"
linear.api.key
resolve-from
fn (opts: Map, ctx-values: Map): Map
The one resolver, pure: {api-key, base-url} for a call from opts first, then ctx-values (a Map of context variables), then defaults. An Err when no API key is set, when api-key is in opts but blank or null (that never falls back to context), or when opts has base-url without api-key. Exposed for testing; resolve feeds it the context.
send-graphql
fn (req: ::hot::http/HttpRequest): Any