0

Get Issue

by
Published today

Get a single issue by its ID or identifier (e.g. ENG-123).

Script linear Verified

The script

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

3
/**
4
 * Get Issue
5
 * Get a single issue by its UUID or its human identifier (e.g. ENG-123).
6
 */
7
export async function main(auth: RT.Linear, issue_id: string) {
8
  const response = await fetch("https://api.linear.app/graphql", {
9
    method: "POST",
10
    headers: {
11
      Authorization: auth.apiKey,
12
      "Content-Type": "application/json",
13
      Accept: "application/json",
14
    },
15
    body: JSON.stringify({
16
      query: `query ($id: String!) { issue(id: $id) { id identifier title description url priority priorityLabel estimate dueDate createdAt updatedAt archivedAt state { id name type } assignee { id name email } team { id key name } project { id name } cycle { id number } parent { id identifier } labels { nodes { id name } } children { nodes { id identifier title } } } }`,
17
      variables: { id: issue_id },
18
    }),
19
  })
20

21
  if (!response.ok) {
22
    throw new Error(`${response.status} ${await response.text()}`)
23
  }
24

25
  const { data, errors } = await response.json()
26
  if (errors) {
27
    throw new Error(JSON.stringify(errors))
28
  }
29

30
  return data.issue
31
}
32