Files
angular__angular/tools/dashboard/functions/github/github-graphql-queries.ts
T
Paul Gschwendtner c021e94fce chore(dashboard): http function to list pull requests with conflicts (#6675)
Introduces a new http trigger in the Dashboard functions that returns all Pull Requests with merge conflicts. This allows us to show a list of PRs with merge conflicts in the dashboard.

To ensure that the API calls are as fast as possible, the pull requests with conflicts are queried using Github's new GraphQL API.
2017-09-28 16:05:46 -07:00

44 lines
1.3 KiB
TypeScript

import {githubApiV4} from './github-api';
/** GraphQL query that finds all Pull Requests and their mergeable state. */
const getOpenPullRequestsWithMergeableStateQuery = `
query getOpenPullRequestsWithMergeableState($lastCursor: String) {
repository(owner: "angular", name: "material2") {
pullRequests(states: OPEN, first: 100, after: $lastCursor) {
pageInfo {
hasNextPage,
endCursor
}
nodes {
number,
mergeable
}
}
}
}`;
/** Pull Request node that will be returned by the Github V4 API. */
export interface PullRequestWithMergeableState {
number: number;
mergeable: string;
}
/** Queries the GitHub API to find all open pull requests and their mergeable state. */
export async function getOpenPullRequestsWithMergeableState()
: Promise<PullRequestWithMergeableState[]> {
const nodes: PullRequestWithMergeableState[] = [];
let lastData: any|null = null;
while (!lastData || lastData.repository.pullRequests.pageInfo.hasNextPage) {
lastData = await githubApiV4.request(getOpenPullRequestsWithMergeableStateQuery, {
lastCursor: lastData && lastData.repository.pullRequests.pageInfo.endCursor
});
nodes.push(...lastData.repository.pullRequests.nodes);
}
return nodes;
}