1 | |
2 |
|
3 | |
4 | * Get View Issues |
5 | * List the issues matched by a saved custom view's filters, most recently updated first. Paginate with after = pageInfo.endCursor. |
6 | */ |
7 | export async function main( |
8 | auth: RT.Linear, |
9 | view_id: string, |
10 | first: number = 50, |
11 | after: string | undefined |
12 | ) { |
13 | const response = await fetch("https://api.linear.app/graphql", { |
14 | method: "POST", |
15 | headers: { |
16 | Authorization: auth.apiKey, |
17 | "Content-Type": "application/json", |
18 | Accept: "application/json", |
19 | }, |
20 | body: JSON.stringify({ |
21 | query: `query ($id: String!, $first: Int, $after: String) { customView(id: $id) { issues(first: $first, after: $after, orderBy: updatedAt) { nodes { id identifier title url priority dueDate createdAt updatedAt state { id name type } assignee { id name email } team { id key } labels { nodes { id name } } } pageInfo { hasNextPage endCursor } } } }`, |
22 | variables: { id: view_id, first, after: after || undefined }, |
23 | }), |
24 | }) |
25 |
|
26 | if (!response.ok) { |
27 | throw new Error(`${response.status} ${await response.text()}`) |
28 | } |
29 |
|
30 | const { data, errors } = await response.json() |
31 | if (errors) { |
32 | throw new Error(JSON.stringify(errors)) |
33 | } |
34 |
|
35 | return data.customView.issues |
36 | } |
37 |
|