//native
/**
* Update Initiative
* Update an initiative. Only the fields you set are changed. Status: Planned, Active, Completed. target_date is YYYY-MM-DD.
*/
export async function main(
auth: RT.Linear,
initiative_id: string,
name: string | undefined,
description: string | undefined,
content: string | undefined,
status:
"Planned" | "Active" | "Completed" | "Proposed" | "Canceled" | undefined,
owner_id: string | undefined,
target_date: string | undefined
) {
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!, $input: InitiativeUpdateInput!) { initiativeUpdate(id: $id, input: $input) { success initiative { id name description url status health targetDate createdAt updatedAt archivedAt owner { id name } projects { nodes { id name } } } } }`,
variables: {
id: initiative_id,
input: {
name: name || undefined,
description: description || undefined,
content: content || undefined,
status: status || undefined,
ownerId: owner_id || undefined,
targetDate: target_date || undefined,
},
},
}),
})
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.initiativeUpdate
}
Submitted by hugo989 2 hours ago