v4: pagination for Issues + PullRequests for a specific repository #24398
-
Github API V3 states “a pull request is an issue, but an issue is not always a pull request, please check for the pull_request key” However, it seems for V4, Issues and PullRequests are a different category, I can paginate each individually, but I can’t wrap my head around getting pagination to work with both of them together … is there a way to do it like V3? Say I grab 50 issues, Issue AND PR, and then paginate with the cursor … or should I just stick with v3 for this? |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments
-
Do you have a sample query to start from? I’m not sure where the problem is from your description. Thanks. |
Beta Was this translation helpful? Give feedback.
-
Whoops, really sorry about the late reply, I thought I’d get a notification on github So say I wanted to query issues by looking at the repo owner, and the name - this is V4 of the API
What it returns is an array of issue nodes … all fine and good, but what it lacks is that issues are separate from pull-requests … I’m guessing that’s the design decision, but it’s different from that of V3, where each issue object returned had a pull_request key, signifying that this issue is also a pull request. However, that means for V4 we would have to query for both issues and pull-requests keep the pageInfo for both …
Which will give us 20 of the most recent of both issues and PRs Now if we were to call V3, then we’ll go ahead and grab the most recent 40 issues - SOME of them PR, but not 50% always, but they’ll always be the most recent 40 issues/PR, and we can tell via the pull_request key. Going back to V4, the particular repo might have the most recent 30 issues be normal issues, and 31-50 being PRs, by my 2nd snippet, we’ll be grabbing 0-19 as issue, then 31-50 as PR, skipping 20-29 So I was wondering if I could do the same thing as api V3 in api V4 Thanks! |
Beta Was this translation helpful? Give feedback.
-
There isn’t a connection that offers pagination, but there is the I hope that helps. |
Beta Was this translation helpful? Give feedback.
-
Please pardon my inexperience, so that would mean, I’d have to to multiple queries then?
I ws hoping to use something like issueOrPullRequest(range of number) Is that acceptable for graphQL? I was under the impression less queries were the best thing… |
Beta Was this translation helpful? Give feedback.
-
You are correct, that you would have to make multiple queries. I agree that the multiple queries would probably be wasteful but it was the only way I could see of obtaining information similar to what is available in the REST API. |
Beta Was this translation helpful? Give feedback.
-
Mhm… I tried quite a bit to see what I can do to use the least amount of queries - but to no avail. I’m guessing Github just decided to separate issues from pull requests for good in v4 to minimize extra data from coming in? And thanks for your answers and patience! |
Beta Was this translation helpful? Give feedback.
You are correct, that you would have to make multiple queries. I agree that the multiple queries would probably be wasteful but it was the only way I could see of obtaining information similar to what is available in the REST API.