Skip to content

hwatkins/ex_linear

ExLinear

Elixir client library for the Linear GraphQL API.

ex_linear provides:

  • A small GraphQL client built on Req
  • Structured errors via %ExLinear.Error{}
  • Cursor pagination helpers for Linear connection fields
  • Typed resource wrappers for teams, users, workflow states, and issues

Installation

Add ex_linear to your dependencies:

def deps do
  [
    {:ex_linear, "~> 0.1.0"}
  ]
end

Quick Start

client = ExLinear.client(System.fetch_env!("LINEAR_API_KEY"))

{:ok, me} = ExLinear.Users.me(client)
{:ok, teams} = ExLinear.Teams.list(client)

Authentication

ExLinear.Client supports two auth header modes.

API key mode (default):

client = ExLinear.Client.new("lin_api_xxx")
# Authorization: lin_api_xxx

Bearer mode (OAuth token):

client = ExLinear.Client.new("oauth_token", auth_type: :bearer)
# Authorization: Bearer oauth_token

Resource Examples

List workflow states for a team:

{:ok, states} = ExLinear.WorkflowStates.list(client, "team_id")

List issues for a team:

{:ok, issues} = ExLinear.Issues.list(client, "team_id")

List issues with filters:

{:ok, issues} =
  ExLinear.Issues.list(client, "team_id",
    priority: 1,
    assignee_id: "user_id"
  )

Create an issue:

{:ok, issue} = ExLinear.Issues.create(client, %{title: "Investigate latency", team_id: "team_id"})

Update and archive an issue:

{:ok, issue} = ExLinear.Issues.update(client, "issue_id", %{state_id: "workflow_state_id"})
{:ok, issue} = ExLinear.Issues.archive(client, "issue_id")

Search issues:

{:ok, matches} = ExLinear.Issues.search(client, "database")

Error Handling

All public calls follow:

  • {:ok, result}
  • {:error, %ExLinear.Error{}}
case ExLinear.Issues.get(client, "issue_id") do
  {:ok, issue} -> IO.inspect(issue)
  {:error, %ExLinear.Error{type: :graphql, message: message}} -> IO.puts(message)
  {:error, %ExLinear.Error{} = error} -> IO.inspect(error)
end

Pagination Behavior

Connection-based list/search calls accumulate all pages internally by following pageInfo.endCursor while pageInfo.hasNextPage is true.

Development

mix deps.get
mix ci.fast
mix ci

License

MIT. See LICENSE.

About

Elixir client library for the Linear GraphQL API

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

No packages published

Languages