//native
/**
* Create Initiative Update
* Post a status update on an initiative. body is Markdown. Health: onTrack, atRisk, offTrack.
*/
export async function main(
auth: RT.Linear,
initiative_id: string,
body: string,
health: "onTrack" | "atRisk" | "offTrack" | 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 ($input: InitiativeUpdateCreateInput!) { initiativeUpdateCreate(input: $input) { success initiativeUpdate { id body health url createdAt updatedAt user { id name } initiative { id name } } } }`,
variables: {
input: {
initiativeId: initiative_id,
body,
health: health || 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.initiativeUpdateCreate
}
Submitted by hugo989 2 hours ago