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

Use GraphQL in ModelService to read PR reviews/comments. #1501

Merged

Conversation

@grokys
Copy link
Contributor

@grokys grokys commented Feb 21, 2018

Ported from #1415.

The REST API filters out pending reviews when reading PR reviews/review comments, making it unusable for the PR reviews feature. This PR updates ModelService to take a GraphQL IConnection and uses that to read PR review comments from the GraphQL API, and in addition reads the related PR reviews too.

This is integrated a bit hackily into ModelService; ModelService doesn't really mesh well with GraphQL, and our existing models are a bit of a strange fit for the (more logical) way that GraphQL uses nested models to represent relationships. However, without a lot of refactoring this was the best way to get things up and running, and more importantly I don't really have a good feel yet as to how we should structure things with GraphQL. As we hopefully move more things to GraphQL in the coming months we should start to get a feel for that.

(As a side note, take a look at how much code is required to do nested paging in GraphQL - I think making this work by default in Ocotokit.GraphQL will be a big deal)

Part of #1491

@grokys grokys mentioned this pull request Feb 21, 2018
17 of 17 tasks complete
@StanleyGoldman StanleyGoldman self-requested a review Feb 22, 2018
@StanleyGoldman
Copy link
Contributor

@StanleyGoldman StanleyGoldman commented Feb 22, 2018

The ghfvs branch is branch of Octokit.GraphQL is being used here?


if (review.CommentPage.HasNextPage)
{
result.AddRange(await GetPullRequestReviewComments(review.Id, review.CommentPage.EndCursor));

This comment has been minimized.

@StanleyGoldman

StanleyGoldman Feb 22, 2018
Contributor

We should throw in some comments that explain this GraphQL a bit, because the pagination is nuanced.
Let me take a stab at it...

  • The above query gets a single page or reviews and for each review a single page of comments.
  • GetPullRequestReviewComments will continue to query the comments per review.
  • The containing for loop will continue this process for each page in this page of reviews
  • The containing while loop will continue this process to obtain all review pages

This comment has been minimized.

@grokys

grokys Mar 19, 2018
Author Contributor

Yep, good point - added some comments, does that make it clearer?

@grokys grokys mentioned this pull request Mar 6, 2018
grokys added 5 commits Feb 21, 2018
And associated factory/keychain classes.
This is integrated a bit hackily into `ModelService`; `ModelService` doesn't really mesh well with GraphQL but without a lot of refactoring this was the best way to get things up and running.
As it's ignored by default.
The cursor was not being used for the first page, or ever in fact because the capitalization was wrong.
...in UnitTests. Akavache uses Newtonsoft.Json 6.0.8 while we use 10.0.3. The earlier version needs to be redirected to the later version for tests to work.
@grokys grokys force-pushed the feature/graphql-modelservice-pr-reviews branch from c649c25 to 0a20262 Mar 19, 2018
@grokys
Copy link
Contributor Author

@grokys grokys commented Mar 19, 2018

The ghfvs branch is branch of Octokit.GraphQL is being used here?

No, that branch can be removed now I think - the stuff in there that were needed by GHfVS has been added to master (strong name signing).

@grokys grokys requested review from shana, sguthals, meaghanlewis and jcansdale Mar 23, 2018
…rvice-pr-reviews

 Conflicts:
	src/GitHub.App/packages.config
Copy link
Collaborator

@jcansdale jcansdale left a comment

Looking good. A few comments but nothing serious.

@@ -366,6 +375,158 @@ IObservable<IReadOnlyList<IRemoteRepositoryModel>> GetOrganizationRepositories(s
});
}

#pragma warning disable CS0618 // DatabaseId is marked obsolete by GraphQL but we need it

This comment has been minimized.

@jcansdale

jcansdale Mar 23, 2018
Collaborator

🚲 You could create a GetDatabaseId method surrounded by #pragma warning disable CS0618 to avoid turning off obsolete warnings for a large block.

This comment has been minimized.

@grokys

grokys Mar 29, 2018
Author Contributor

That won't work here as these expressions are converted at runtime to GraphQL queries, and the expression rewriter can't introspect such a method, so building the query will fail.

}
return data;
}
catch (Exception ex)

This comment has been minimized.

@jcansdale

jcansdale Mar 23, 2018
Collaborator

I'm guessing this will show a build warning? Replace with catch { }. Trying to keep the build clean. 😉

@jcansdale jcansdale merged commit 774fa48 into feature/pr-reviews-master Mar 28, 2018
2 checks passed
2 checks passed
continuous-integration/appveyor/branch AppVeyor build succeeded
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
@jcansdale jcansdale deleted the feature/graphql-modelservice-pr-reviews branch Mar 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.