//native
/**
* List Labels
* List issue labels. With team_id, only that team's labels are returned (workspace-wide labels are excluded). Paginate with after = pageInfo.endCursor.
*/
export async function main(
auth: RT.Linear,
team_id: string | undefined,
first: number = 100,
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: IssueLabelFilter, $first: Int, $after: String) { issueLabels(filter: $filter, first: $first, after: $after) { nodes { id name color description isGroup team { id key } parent { id name } } pageInfo { hasNextPage endCursor } } }`,
variables: {
filter: team_id ? { team: { id: { eq: team_id } } } : undefined,
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.issueLabels
}
Submitted by hugo989 1 hour ago