//native
/**
* Get Initiative
* Get a single initiative by its ID, with its projects and latest update.
*/
export async function main(auth: RT.Linear, initiative_id: string) {
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: `query ($id: String!) { initiative(id: $id) { id name description url status health targetDate createdAt updatedAt archivedAt owner { id name } projects { nodes { id name } } content lastUpdate { id body health createdAt } } }`,
variables: { id: initiative_id },
}),
})
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.initiative
}
Submitted by hugo989 2 hours ago