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

Generalize PagedQuery to allow its reuse by preview github APIs #439

Merged
merged 1 commit into from
May 26, 2020
Merged

Generalize PagedQuery to allow its reuse by preview github APIs #439

merged 1 commit into from
May 26, 2020

Conversation

TomMD
Copy link
Contributor

@TomMD TomMD commented Apr 28, 2020

I've been greatly enjoying the GitHub package as well as the principled approach when considering new APIs and changes. Users pop up from time to time wanting to use another API and GitHub's insistence that many APIs remain beta for an extended period of time has been an hinderance - the machine-man-preview and shadowcat APIs for example.

Github- style packages can be made to support these APIs - it would be great to benefit from all the rich machinery developed here in the github package when doing so. This PR has one small change that doesn't appear to impact the github package's major Haskell APIs, but helps tremendously with reusing github (package) on some preview github (web service) APIs.

Enough preamble! This pull request relaxes PagedQuery from vector to any semigroup foldable. That is:

PagedQuery   :: Paths -> QueryString -> FetchCount -> GenRequest mt rw (Vector a)

To:

PagedQuery   :: (a ~ t b, Foldable t, Semigroup a) => Paths -> QueryString -> FetchCount -> GenRequest mt rw a

The consumer of PagedQuery already was generalized to Semigroup but the predicate used vector length, so the consumer only needed to drop V. - using foldable length - and everything works as before. That's all that is required for re-use of the pagination machinery for several not-yet-standard APIs.

@phadej
Copy link
Contributor

phadej commented Apr 28, 2020

That's all that is required for re-use of the pagination machinery for several not-yet-standard APIs.

Could you expand on this. Something returning non-Vectors?

@TomMD
Copy link
Contributor Author

TomMD commented Apr 28, 2020

Something returning non-Vectors?

A number of things return non-vector that have become pretty every-day in GitHub, though still behind a preview header. Listing repositories and installations, using search.

There's even some that are standard- not a preview any longer - artifacts uses the same JSON structure as the above ({ "total_count" : Int, someField : [ Values ] }). Workflows is yet another. There are more.

@TomMD
Copy link
Contributor Author

TomMD commented May 25, 2020

It seems this change doesn't impact the vast majority of the API and users. It appears standard GitHub APIs aren't accessible without some sort of change - such as the one proposed here. What are your thoughts on moving forward?

@phadej
Copy link
Contributor

phadej commented May 25, 2020

I think it's good. I'll try to find time to go through github backlog this week.

@phadej phadej merged commit e5a1acc into haskell-github:master May 26, 2020
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.

2 participants