* Fetches all labels from a repository, paginating through all pages. * @param {any} githubClient - GitHub API client * @param {string} owner - Repository owner * @param {string} repo - Repository name * @returns {Promise >} All repository labels
(githubClient, owner, repo)
| 108 | * @returns {Promise<Array<{id: string, name: string}>>} All repository labels |
| 109 | */ |
| 110 | async function fetchAllRepoLabels(githubClient, owner, repo) { |
| 111 | const labelsQuery = ` |
| 112 | query($owner: String!, $repo: String!, $cursor: String) { |
| 113 | repository(owner: $owner, name: $repo) { |
| 114 | labels(first: 100, after: $cursor) { |
| 115 | nodes { |
| 116 | id |
| 117 | name |
| 118 | } |
| 119 | pageInfo { |
| 120 | hasNextPage |
| 121 | endCursor |
| 122 | } |
| 123 | } |
| 124 | } |
| 125 | } |
| 126 | `; |
| 127 | |
| 128 | const allLabels = /** @type {Array<{id: string, name: string}>} */ []; |
| 129 | let cursor = /** @type {string | null} */ null; |
| 130 | let hasNextPage = true; |
| 131 | |
| 132 | while (hasNextPage) { |
| 133 | const queryResult = await githubClient.graphql(labelsQuery, { owner, repo, cursor }); |
| 134 | const labelsPage = queryResult?.repository?.labels; |
| 135 | const nodes = labelsPage?.nodes || []; |
| 136 | allLabels.push(...nodes); |
| 137 | hasNextPage = labelsPage?.pageInfo?.hasNextPage ?? false; |
| 138 | cursor = labelsPage?.pageInfo?.endCursor ?? null; |
| 139 | } |
| 140 | |
| 141 | return allLabels; |
| 142 | } |
| 143 | |
| 144 | /** |
| 145 | * Resolves the top-level parent comment node ID for GitHub Discussion replies. |
no outgoing calls
no test coverage detected