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 ¶
const DefaultURL = "https://api.linear.app/graphql"
DefaultURL is the endpoint of linear.app.
Variables ¶
var ErrForbidden = errors.New("linear refused the query")
ErrForbidden marks a query the key is not allowed to make.
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.
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 (*Client) Query ¶
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.