//native
/**
* List Initiative Updates
* List initiative status updates, newest first, optionally for a single initiative. Paginate with after = pageInfo.endCursor.
*/
export async function main(
auth: RT.Linear,
initiative_id: string | undefined,
include_archived: boolean = false,
first: number = 50,
after: 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: `query ($filter: InitiativeUpdateFilter, $includeArchived: Boolean, $first: Int, $after: String) { initiativeUpdates(filter: $filter, includeArchived: $includeArchived, first: $first, after: $after, orderBy: createdAt) { nodes { id body health url createdAt updatedAt user { id name } initiative { id name } } pageInfo { hasNextPage endCursor } } }`,
variables: {
filter: initiative_id
? { initiative: { id: { eq: initiative_id } } }
: undefined,
includeArchived: include_archived,
first,
after: after || 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.initiativeUpdates
}
Submitted by hugo989 2 hours ago