1 | |
2 |
|
3 | |
4 | * Update Issue |
5 | * Update an issue. Only the fields you set are changed. added_label_ids / removed_label_ids add or remove labels without touching the others. Priority: 0 none, 1 urgent, 2 high, 3 medium, 4 low. |
6 | */ |
7 | export async function main( |
8 | auth: RT.Linear, |
9 | issue_id: string, |
10 | title: string | undefined, |
11 | description: string | undefined, |
12 | state_id: string | undefined, |
13 | assignee_id: string | undefined, |
14 | priority: number | undefined, |
15 | due_date: string | undefined, |
16 | project_id: string | undefined, |
17 | cycle_id: string | undefined, |
18 | parent_id: string | undefined, |
19 | added_label_ids: string[] | undefined, |
20 | removed_label_ids: string[] | undefined |
21 | ) { |
22 | const response = await fetch("https://api.linear.app/graphql", { |
23 | method: "POST", |
24 | headers: { |
25 | Authorization: auth.apiKey, |
26 | "Content-Type": "application/json", |
27 | Accept: "application/json", |
28 | }, |
29 | body: JSON.stringify({ |
30 | query: `mutation ($id: String!, $input: IssueUpdateInput!) { issueUpdate(id: $id, input: $input) { success issue { 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 } } } } }`, |
31 | variables: { |
32 | id: issue_id, |
33 | input: { |
34 | title: title || undefined, |
35 | description: description || undefined, |
36 | stateId: state_id || undefined, |
37 | assigneeId: assignee_id || undefined, |
38 | priority, |
39 | dueDate: due_date || undefined, |
40 | projectId: project_id || undefined, |
41 | cycleId: cycle_id || undefined, |
42 | parentId: parent_id || undefined, |
43 | addedLabelIds: added_label_ids?.length ? added_label_ids : undefined, |
44 | removedLabelIds: removed_label_ids?.length |
45 | ? removed_label_ids |
46 | : undefined, |
47 | }, |
48 | }, |
49 | }), |
50 | }) |
51 |
|
52 | if (!response.ok) { |
53 | throw new Error(`${response.status} ${await response.text()}`) |
54 | } |
55 |
|
56 | const { data, errors } = await response.json() |
57 | if (errors) { |
58 | throw new Error(JSON.stringify(errors)) |
59 | } |
60 |
|
61 | return data.issueUpdate |
62 | } |
63 |
|