Repository navigation
Merge JSON responses from gh api - #8620
Conversation
|
Whoops. Forgot we decided to do this as a new parameter: Could we rebase merge this when done? I will keep the commits clean. Might be good to keep the current commit with the necessary logic. Alternatively, I could put in some TODO comments for a future change. |
|
Thanks for providing this as an example of how
Not sure what the intent is here sorry. I don't understand what rebasing on |
|
The eventual goal after talking with @andyfeller was to deprecate More comments will be over on cli/go-gh#148. |
|
@williammartin I ran into an issue when porting some of my old tests from #5652 that would be better served by bifurcating the logic. I will try to work around it given our discussion in cli/go-gh#148, but the problem is basically that the existing code only merges if there's no template; however, that ends up executing the template for each page, so the table alignment from Consider two pages: [{"id":1,"title":"one"}][{"id":20,"title":"twenty"}]It should render as: However, because the template is executed for each page, that first page width is 1 less character: Because of the refactoring I made in #5652 it actually worked correctly. The template execution happened later after merging was complete. And this worked for both REST and GraphQL responses because either were cached until the last page was read and merged. Because Nate's solution for REST responses no longer caches - which I've maintained here for reasons we discussed in #5652 - I could only do this for GraphQL responses currently. Assuming I can work around this - and I'm updating status here in case I don't finish tonight, but I'll push what I have with that one test disabled for now - the future refactoring should take this into account. UPDATE: I was able to work around this. Actually, it was because my old test intentionally added |
|
Given further discussions about stability, @andyfeller @williammartin do we still want to add UPDATE: Thinking about this more, maybe we should consider a Still, marking the PR ready. I updated everything per discussions, but I'm open to changing a few things as suggested above. |
|
Because of the two comments that were also later updated I'm not sure how much of them is still considered relevant, so excuse me if these questions seem to have obvious answers.
I don't understand your question. Are you talking about the flag, or the behaviour?
What error cases?
I don't really have a strong opinion but I'm also not really following why you would prefer Re: all the Thanks! |
|
The discussion @andyfeller, Sam, and I had back in December was that this would be temporary until we see enough usage of merged pagination without regressions - even though I think, with the addition of more tests I added, we have a good battery of tests. I appreciate the emphasis on backward compatibility where it makes sense to. |
|
Understood. The only reason I leaned slightly towards
To be specific, the follow up notes from the call target this behavioural change for a major version:
I’m sure this is clear to you already but for the sake of posterity for anyone reading this in the future, the issue at hand is that any user depending on interrogating the output of something like: might be broken by changing
Not that our users would be insane for this but that if a CLI regresses and no one is around to notice it, did it really regress. |
Possibly, but that seems incredibly unlikely. The CLI would emit multiple pages like so: {
"data": {
"viewer": {
"repositories": {
"nodes": [{"nameWithOwner": "heaths/cli"}]
}
}
}
}
{
"data": {
"viewer": {
"repositories": {
"nodes": [{"nameWithOwner": "heaths/cli"}]
}
}
}
}Currently, that's invalid JSON. You can't pass it to Now, lets say that someone wrote a script (as I did before starting the original work) that looks for That said, and re:
Thank you. I had forgotten not only that part of the discussion about the next major version but didn't realize or forgot we wrote down meeting notes in the issue. That does make sense, and while I think the risk of regression is slim to none, I agree it makes sense to wait to truly fix this in v3.
I like |
I was surprised to find that at least on my machine
I also think that most likely regressions are unlikely and it's actually likely that most regressions would have been indicative of a buggy script but I think waiting till v3 is the safest option.
I've given enough projects terrible names in my time to keep my mouth zipped 😬 |
|
I'll rename the switch and rejigger a bit of the logic and let you know. Probably tonight. Looks like I need to rebase again, but at least this has been clean so far unlike my first PR for this issue. BTW, sorry for updating comments previously. I've typically done this when I expect the person is either 1) further away with a large offset in time zone, or 2) is close to me, but I'm active at a time later than they would usually be. It's the whole chunky vs. chatty discussion dilemma. While it may not have helped in this case (since I was up late and all I can glean from your profile is that you at least visited the Golden Gate bridge at some point), I did file a feature request: https://github.com/orgs/community/discussions/102931 I find the TZ offset in Teams to help communicating with partner teams to help decide if I should having a chunky reply or expect a chatty back-and-forth. |
I frequently have to switch tools - and always have to refer back to docs - that use either |
|
Ah well for future reference I'm in Amsterdam, NL and I've updated my profile to reflect that. Not a problem with the updates. |
|
@williammartin this should be ready now. I removed the "experimental" notes given this is an additional flag that still requires |
|
Wait: something is wrong. Tests pass, but I just tried it in a use case and it still emits separate pages and a final blank |
|
@williammartin I realized the problem: I forgot, to maintain backcompat, this only works when piping or redirecting stdout. When I was testing it, I was just printing to the terminal. Still, that showed me that To note, For a future v3, there's definitely a lot of room for improvement. For example, I think the merging behavior should be default but, IMO, I would use |
|
PS: seems the |

Partly resolves #1268 and replaces #5652. Requires cli/go-gh#148 to be merged and optionally released.
internalpackage.gh api#5652.--paginate-allswitch.See cli/go-gh#148 for a full discussion.