linear

package
v0.13.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 25, 2026 License: Apache-2.0 Imports: 11 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package linear is a small read-only client of the Linear GraphQL API. It sends queries and never a mutation. It waits out rate limits and retries server errors.

Index

Constants

View Source
const DefaultURL = "https://api.linear.app/graphql"

DefaultURL is the endpoint of linear.app.

Variables

View Source
var ErrForbidden = errors.New("linear refused the query")

ErrForbidden marks a query the key is not allowed to make.

View Source
var ErrServer = errors.New("linear server error")

ErrServer marks a failure on Linear's side that a smaller request may avoid, such as a timeout on a heavy query.

View Source
var ErrTooComplex = errors.New("linear found the query too complex")

ErrTooComplex marks a query that costs more than Linear allows for one request. A smaller page costs less.

Functions

This section is empty.

Types

type Client

type Client struct {
	// Key is sent as the Authorization header as it is. A personal API key
	// goes in bare. An OAuth token goes in with its "Bearer " prefix.
	Key string
	// URL is the GraphQL endpoint.
	URL  string
	HTTP *http.Client
	// MaxWait is the longest single rate-limit wait the client accepts before
	// it gives up with an error that names the wait.
	MaxWait time.Duration
	// Logf receives progress lines, such as rate-limit waits. May be nil.
	Logf func(format string, a ...any)
	// Waiting is told how long the client is about to wait for a rate limit.
	// A display that sets it shows the wait itself, so the wait is then not
	// sent to Logf as well. May be nil.
	Waiting func(time.Duration)
	// UserAgent is sent with every request.
	UserAgent string

	// Calls counts HTTP requests sent, including retries. Read it when no
	// request is in flight.
	Calls int
	// contains filtered or unexported fields
}

Client talks to one Linear API endpoint.

func New

func New(key string) *Client

New returns a client for linear.app.

func (*Client) Query

func (c *Client) Query(ctx context.Context, query string, vars map[string]any, out any) error

Query runs a query and decodes the "data" object into out. Mutations and subscriptions are refused: this client is read-only by construction.

Linear answers a query that partly failed with status 200, an "errors" list and what data it has. Such an answer is an error here, so half a page is never taken for a whole one.

func (*Client) Requests added in v0.2.0

func (c *Client) Requests() int

Requests is the number of HTTP requests sent so far. Unlike Calls it is safe to read while requests are in flight.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL