//native
/**
* Archive Issue
* Archive an issue. Set trash to move it to the trash instead (deleted after 30 days).
*/
export async function main(
auth: RT.Linear,
issue_id: string,
trash: boolean = false
) {
const response = await fetch("https://api.linear.app/graphql", {
method: "POST",
headers: {
Authorization: auth.apiKey,
"Content-Type": "application/json",
Accept: "application/json",
},
body: JSON.stringify({
query: `mutation ($id: String!, $trash: Boolean) { issueArchive(id: $id, trash: $trash) { success entity { id identifier archivedAt trashed } } }`,
variables: { id: issue_id, trash },
}),
})
if (!response.ok) {
throw new Error(`${response.status} ${await response.text()}`)
}
const { data, errors } = await response.json()
if (errors) {
throw new Error(JSON.stringify(errors))
}
return data.issueArchive
}
Submitted by hugo989 1 hour ago