Skip to content

Loading Pull Request List via GraphQL - #1022

Closed
Stanley Goldman (StanleyGoldman) wants to merge 11 commits into
mainfrom
pull-request-list-via-graphql
Closed

Loading Pull Request List via GraphQL#1022
Stanley Goldman (StanleyGoldman) wants to merge 11 commits into
mainfrom
pull-request-list-via-graphql

Conversation

@StanleyGoldman

@StanleyGoldman Stanley Goldman (StanleyGoldman) commented Mar 4, 2019

Copy link
Copy Markdown
Contributor

In order to implement (#1020), this pull request changes functionality to query for the pull request list via GraphQL. REST API calls to obtain Pull Request list items do not include the mergeable flag.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some old artifacts were found and removed.

interface PageInformation {
pullRequestPage: number;
hasMorePages: boolean;
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be an artifact from an old implementation.

public collapsibleState: vscode.TreeItemCollapsibleState;
public prs: PullRequestModel[];
public fetchNextPage: boolean = false;
public repositoryPageInformation: Map<string, PageInformation> = new Map<string, PageInformation>();

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As does this.

Comment thread src/github/pullRequestManager.ts Outdated
state: pullRequestItem.state,
title: pullRequestItem.title,
user: pullRequestItem.author
};

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mapping the graphql object to an object the PullRequestModel consumes. Not thrilled about doing this here.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the file src/github/utils.ts has functions for mapping response types to normalized types

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, i'll move the code.

Comment thread src/github/graphql.ts Outdated
Comment thread src/github/graphql.ts Outdated

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! it's interesting to see what non-Relay gql code looks like since I've only ever used Relay.

Left a few comments -- would be good for somebody else to be the approving reviewer though since I am just getting familiar with this code base.

}
async getPullRequestsGraphQL(type: PRType, nextCursor?: string|null):Promise<PullRequestListResponse|undefined> {
const { remote, query, octokit } = await this.ensure();
const currentUser = octokit && (octokit as any).currentUser;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just out of curiosity, why octokit as any? Do we not have ts bindings for octokit or something?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a similar question as I'm pretty sure the bindings exist.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, we do have bindings for octokit, but currentUser is something we've added ourselves

#600 (review)

We also added an octokit.ts file a while ago that modifies the typings slightly, there was something that should have been nullable that wasn't. currentUser can be added there to get rid of our any casts. But I think we should ultimately try to get rid of that file by correcting the typings upstream

}
)
.filter(item => item !== null) as PullRequestModel[];
let filter = `type:pr is:open repo:${remote.owner}/${remote.repositoryName}`;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be a little edge casey, but do we need to guard against the remote being null here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would say yes, but looking at all the other calls to ensure to get remote seem to make the assumption that remote will not be null.

Comment thread src/github/githubRepository.ts Outdated
Comment thread src/github/githubRepository.ts Outdated
const currentUser = octokit && (octokit as any).currentUser;
const currentUserLogin: string = currentUser.login;

private async getAllPullRequests(page?: number): Promise<PullRequestData | undefined> {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should remove this - we still need to support GHE that doesn't have GraphQL

} else {
throw e;
}
if(!!nextCursor) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious why you use if(!!condition) here, instead of if(condition)

Base automatically changed from master to main February 17, 2021 21:41
@alexr00

Copy link
Copy Markdown
Member

Thanks for the PR Stanley Goldman (@StanleyGoldman). Since the goal of this PR was to enable #681, I'm going to close it. We already have #681 as of the last stable release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants