diff --git a/.changeset/sweet-fishes-taste.md b/.changeset/sweet-fishes-taste.md new file mode 100644 index 0000000000..f064cd459d --- /dev/null +++ b/.changeset/sweet-fishes-taste.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-github-pull-requests-board': patch +--- + +The PR dashboard will now show more than 10 pull requests at one time. diff --git a/plugins/github-pull-requests-board/src/api/useGetPullRequestsFromRepository.ts b/plugins/github-pull-requests-board/src/api/useGetPullRequestsFromRepository.ts index bd5df89833..89812ef54b 100644 --- a/plugins/github-pull-requests-board/src/api/useGetPullRequestsFromRepository.ts +++ b/plugins/github-pull-requests-board/src/api/useGetPullRequestsFromRepository.ts @@ -26,27 +26,41 @@ export const useGetPullRequestsFromRepository = () => { async (repo: string): Promise => { const [organisation, repositoryName] = repo.split('/'); - const { repository } = await graphql( - ` - query ($name: String!, $owner: String!) { - repository(name: $name, owner: $owner) { - pullRequests(states: OPEN, first: 10) { - edges { - node { - number + const pullRequestEdges = []; + let result: GraphQlPullRequests | undefined = + undefined; + do { + result = await graphql( + ` + query ($name: String!, $owner: String!, $endCursor: String) { + repository(name: $name, owner: $owner) { + pullRequests(states: OPEN, first: 100, after: $endCursor) { + edges { + node { + number + } + } + pageInfo { + hasNextPage + endCursor } } } } - } - `, - { - name: repositoryName, - owner: organisation, - }, - ); + `, + { + name: repositoryName, + owner: organisation, + endCursor: result + ? result.repository.pullRequests.pageInfo.endCursor + : undefined, + }, + ); - return repository.pullRequests.edges; + pullRequestEdges.push(...result.repository.pullRequests.edges); + } while (result.repository.pullRequests.pageInfo.hasNextPage); + + return pullRequestEdges; }, ); diff --git a/plugins/github-pull-requests-board/src/utils/types.tsx b/plugins/github-pull-requests-board/src/utils/types.tsx index a2b121a1b8..a1e2dbfda3 100644 --- a/plugins/github-pull-requests-board/src/utils/types.tsx +++ b/plugins/github-pull-requests-board/src/utils/types.tsx @@ -23,6 +23,10 @@ export type GraphQlPullRequests = { repository: { pullRequests: { edges: T; + pageInfo: { + hasNextPage: boolean; + endCursor?: string; + }; }; }; };