//native
/**
* Search Issues
* Full-text search over issue titles and descriptions, optionally including comments. Results from team_id are ranked higher. Paginate with after = pageInfo.endCursor.
*/
export async function main(
auth: RT.Linear,
term: string,
team_id: string | undefined,
include_comments: boolean = false,
include_archived: boolean = false,
first: number = 25,
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 ($term: String!, $teamId: String, $includeComments: Boolean, $includeArchived: Boolean, $first: Int, $after: String) { searchIssues(term: $term, teamId: $teamId, includeComments: $includeComments, includeArchived: $includeArchived, first: $first, after: $after) { nodes { id identifier title description url priority priorityLabel estimate dueDate createdAt updatedAt archivedAt state { id name type } assignee { id name email } team { id key name } project { id name } cycle { id number } parent { id identifier } labels { nodes { id name } } } pageInfo { hasNextPage endCursor } totalCount } }`,
variables: {
term,
teamId: team_id || undefined,
includeComments: include_comments,
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.searchIssues
}
Submitted by hugo989 1 hour ago