[Bug] v4 (GraphQL) API: Trouble retrieving pull request review comments #24666
-
Howdy! I’m running into a couple of issues using your (wonderful) v4 API. I found a couple of possibly-related threads on your read-only platform forum, but I wanted to mention them here in hopes that there is an available solution. The crux of what I’m trying to do is I’m trying to retrieve all
Surprisingly, this always returns zero
Even more strangely, this returns some of the pull request comments. The response seems to be omitting all but the first comment associated with each commented-on line.
This solution made a bit of sense given the second solution’s incompleteness: comments are likely threaded, given the I’ve considered one possible workaround, which is to use the v3 API (as it apparently returns all review comments related to a pull request), but we are consuming enough data per token from your API that this wouldn’t perform at scale. Hoping to find a solution that allows us to continue to query the v4 API for this data. |
Beta Was this translation helpful? Give feedback.
Replies: 12 comments
-
Hey @nporteschaikin! I am glad you are finding the v4 API wonderful - I think you’ve found a less-than-wonderful gap in the information that’s available. Looking at it today, I think the way to get this information would be to do a lot of work using the
If you look at the id of the `eplyTo field on the comments, you should be able to take a look at what comments and reviews are “top level”, and what comments are attributed to them. Unfortunately, this is not a great UX! As you’ve discovered in those earlier issues, this has been an issue for quite some time (sorry @rnystrom and @yakov116, @hsborges and everyone else who we let down this time and others). I’ve got some GraphQL Schema in development that would allow someone to query something like this:
Which, for the infamous issue GitHawkApp/GitHawk#555 as mentioned in other threads, would return something like this:
How does that sound? I’ll keep this thread up to date as we look to release this. Separately, to people I’ve mentioned in this issue (including you @nporteschaikin): I am sure you’ve got more schema suggestions, frustrations, or anything of the sort. If you’re interested in chatting about them with me, I’d love to sit down over a video chat and go through what’s got you down with our public GraphQL API. |
Beta Was this translation helpful? Give feedback.
-
@k0shk0sh do you have any input for us? |
Beta Was this translation helpful? Give feedback.
-
Hi @nickvanw, Thanks for getting back to me and for your detailed response! We’re heavy users of your GraphQL API at Code Climate and it’s been mostly a pleasant experience :slight_smile:
In my experience, this wouldn’t solve the issue we’re running into. It looks like the response we receive from GraphQL (mostly) does not include replies to comments - rather, we’re receiving all top-level comments, which we can’t connect to their replies. Please correct me if I’m misunderstanding something! A For now, we’re using the v3 API, although - as you could imagine - it’s significantly more challenging to extract this data at scale via the traditional REST API. I look forward to seeing the As for additional feedback on the GraphQL API, I’d love to hop on a call and chat! As alluded to above, we’re extracting a lot of data, regularly, from the v4 API and I think we’ve collected a lot of wisdom, best practices, and feedback for GitHub. I’d love to shoot you an email - let me know how to reach you privately! |
Beta Was this translation helpful? Give feedback.
-
Hey @nporteschaikin, I’m happy to hear that! Perhaps we may be speaking about different things - looking at the query I posted earlier that works now, I believe one could re-create the Taking the output of that query and plugging it into this hastily written python:
Using the Issue I used earlier, GitHawkApp/GitHawk#555, I get the following:
As a rough cut, this seems to me to be the equivalent of the reviewThreads connection I talked about releasing earlier - three total review request threads, one of which having three comments and the other only having the top-level comment. I haven’t tested it exhaustively, though I think the approach would still work. If I’ve mischaracterized anything, please let me know! I’m working on getting the Separately, please reach out to partnerengineering@github.com and mention this thread - we’ll be expecting you, and we can set up a chat! |
Beta Was this translation helpful? Give feedback.
-
Hmm. The problem for us is that the replies are not being returned, so the
The only comment being returned by the GraphQL API is comment A, the “parent” comment. |
Beta Was this translation helpful? Give feedback.
-
Do you have an example of a public PR where you’re experiencing this? The top level reviews connection will only return the top level comments, but the comments connection inside of that seems to give me all of the information I expect. Specifically, I want to make sure you’re trying the I’d love to find an example where I can reproduce what you’re talking about, but I’ve been going around to a few PRs and it seems to be returning what I’d expect. |
Beta Was this translation helpful? Give feedback.
-
Thanks for getting back to me so quickly, @nickvanw. I’m experiencing this exclusively with private repositories, so I’m going to dig into the payload further and see if I’m missing something. Will report back. |
Beta Was this translation helpful? Give feedback.
-
Hey @nporteschaikin! Remember that reviewThreads connection I was talking about earlier? I have good news! If you use the Pull Requests Preview, you should be able to run this query:
This was just shipped, so the documentation should be updating soon. I’d love some feedback on whether this solves your issue(s)! |
Beta Was this translation helpful? Give feedback.
-
Hi @nickvanw! I’m going to take this for a spin. Are these objects also available via the |
Beta Was this translation helpful? Give feedback.
-
At present moment, you can only fetch these threads by looking at this particular connection. I believe re-creating the timeline exactly as it looks on GitHub will take some munging and additional work – if something looks amiss, please let me know. If any other issues persist, or something doesn’t seem right, please don’t hesitate to reach out! |
Beta Was this translation helpful? Give feedback.
-
Is there any reason why it’s
and not
? Also it would be great to have review ID in the thread itself. |
Beta Was this translation helpful? Give feedback.
-
Hi! I don’t think Currently, you have to paginate through all the data under You have to use hacky approaches like in the following:
NamanShergill/diohub/blob/69b13ab65f5ffef13e448d4f3241ae997a3bfdc9/lib/services/pulls/pulls_service.dart#L149 |
Beta Was this translation helpful? Give feedback.
Hey @nporteschaikin!
Remember that reviewThreads connection I was talking about earlier? I have good news!
If you use the Pull Requests Preview, you should be able to run this query: