0

List Project Statuses

by
Published today

List the workspace's project statuses.

Script linear Verified

The script

Submitted by hugo989 Typescript (fetch-only)
Verified 1 hour ago
1
//native
2

3
/**
4
 * List Project Statuses
5
 * List the workspace's project statuses. Use an id as status_id in Update Project. Types: backlog, planned, started, paused, completed, canceled.
6
 */
7
export async function main(
8
  auth: RT.Linear,
9
  first: number = 50,
10
  after: string | undefined
11
) {
12
  const response = await fetch("https://api.linear.app/graphql", {
13
    method: "POST",
14
    headers: {
15
      Authorization: auth.apiKey,
16
      "Content-Type": "application/json",
17
      Accept: "application/json",
18
    },
19
    body: JSON.stringify({
20
      query: `query ($first: Int, $after: String) { projectStatuses(first: $first, after: $after) { nodes { id name type color position description } pageInfo { hasNextPage endCursor } } }`,
21
      variables: { first, after: after || undefined },
22
    }),
23
  })
24

25
  if (!response.ok) {
26
    throw new Error(`${response.status} ${await response.text()}`)
27
  }
28

29
  const { data, errors } = await response.json()
30
  if (errors) {
31
    throw new Error(JSON.stringify(errors))
32
  }
33

34
  return data.projectStatuses
35
}
36