Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loading Pull Request List via GraphQL #1022

Closed
wants to merge 11 commits into from

Conversation

StanleyGoldman
Copy link
Contributor

@StanleyGoldman StanleyGoldman commented Mar 4, 2019

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.

@StanleyGoldman StanleyGoldman requested review from queerviolet, RMacfarlane and rebornix and removed request for queerviolet and RMacfarlane March 4, 2019 15:46
Copy link
Contributor Author

@StanleyGoldman StanleyGoldman left a comment

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
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.

export class CategoryTreeNode extends TreeNode implements vscode.TreeItem {
public readonly label: string;
public collapsibleState: vscode.TreeItemCollapsibleState;
public prs: PullRequestModel[];
public fetchNextPage: boolean = false;
public repositoryPageInformation: Map<string, PageInformation> = new Map<string, PageInformation>();
Copy link
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.

state: pullRequestItem.state,
title: pullRequestItem.title,
user: pullRequestItem.author
};
Copy link
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
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
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.

src/github/graphql.ts Outdated Show resolved Hide resolved
src/github/graphql.ts Outdated Show resolved Hide resolved
Copy link

@annthurium annthurium left a comment

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;

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
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
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}`;

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
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.

src/github/githubRepository.ts Outdated Show resolved Hide resolved

private async getAllPullRequests(page?: number): Promise<PullRequestData | undefined> {
Copy link
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

@meaghanlewis meaghanlewis mentioned this pull request Mar 5, 2019
7 tasks
} else {
throw e;
}
if(!!nextCursor) {
Copy link

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)

@meaghanlewis meaghanlewis mentioned this pull request Apr 8, 2019
7 tasks
Base automatically changed from master to main February 17, 2021 21:41
@alexr00
Copy link
Member

alexr00 commented Dec 15, 2022

Thanks for the PR @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.

@alexr00 alexr00 closed this Dec 15, 2022
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