Browse Source

Fixes issue with filter prs by state

main
Eric Amodio 4 years ago
parent
commit
2a0c00aab3
1 changed files with 4 additions and 3 deletions
  1. +4
    -3
      src/github/github.ts

+ 4
- 3
src/github/github.ts View File

@ -26,11 +26,11 @@ export class GitHubApi {
const cc = Logger.getCorrelationContext(); const cc = Logger.getCorrelationContext();
try { try {
const query = `query pr($owner: String!, $repo: String!, $branch: String!, $limit: Int!, $states: [PullRequestState!], $avatarSize: Int) {
const query = `query pr($owner: String!, $repo: String!, $branch: String!, $limit: Int!, $include: [PullRequestState!], $avatarSize: Int) {
repository(name: $repo, owner: $owner) { repository(name: $repo, owner: $owner) {
refs(query: $branch, refPrefix: "refs/heads/", first: 1) { refs(query: $branch, refPrefix: "refs/heads/", first: 1) {
nodes { nodes {
associatedPullRequests(first: $limit, orderBy: {field: UPDATED_AT, direction: DESC}, states: $states) {
associatedPullRequests(first: $limit, orderBy: {field: UPDATED_AT, direction: DESC}, states: $include) {
nodes { nodes {
author { author {
login login
@ -56,6 +56,8 @@ export class GitHubApi {
} }
}`; }`;
options = { limit: 1, ...options };
const rsp = await graphql<{ const rsp = await graphql<{
repository: repository:
| { | {
@ -75,7 +77,6 @@ export class GitHubApi {
branch: branch, branch: branch,
headers: { authorization: `Bearer ${token}` }, headers: { authorization: `Bearer ${token}` },
...options, ...options,
limit: options?.limit ?? 1,
}); });
const pr = rsp?.repository?.refs.nodes[0]?.associatedPullRequests?.nodes?.[0]; const pr = rsp?.repository?.refs.nodes[0]?.associatedPullRequests?.nodes?.[0];

Loading…
Cancel
Save