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

Pagination API Brainstorm #29

Closed
dillonkearns opened this issue Jan 28, 2018 · 6 comments
Closed

Pagination API Brainstorm #29

dillonkearns opened this issue Jan 28, 2018 · 6 comments

Comments

@dillonkearns
Copy link
Owner

I would like to collect use cases and ideas about pagination helpers in dillonkearns/graphqelm. I made a simple concrete example that does basic pagination using the Github API: examples/src/GithubPagination.elm.

Here is some reference material:

Facebook's Relay Connections Cursor Specification - this describes the standard format for pagination in GraphQL.
Post from Apollo blog on understanding connections - this explains it in more practical terms.

Apollo has a fetchMore function, but it may not be so relevant in the context of Elm because of the very different way of performing side-effects and using types:
https://www.apollographql.com/docs/react/recipes/pagination.html
Here's a blog post describing pagination with Apollo.

In my example code at the top of this post, it seems fairly straightforward without any helper functions and it's hard to imagine helper functions making it easier. I may be missing something or not accounting for some use cases, though. I'd love to hear other people's ideas on how pagination could be made simpler with helper functions or generated code.

@pzingg
Copy link

pzingg commented Mar 4, 2018

Whatever you choose, please make it compatible with Elixir's Absinthe.Relay server side implementation. https://github.com/absinthe-graphql/absinthe_relay

@dillonkearns
Copy link
Owner Author

Good idea, I'll use that in my experiments thanks @pzingg :-)

@dillonkearns
Copy link
Owner Author

Closing this for now to reduce noise. I'll refer back to this thread when I consider this issue more.

@Maxim-Filimonov
Copy link
Contributor

Okay, let's give it a go. If i'm staring away too much from Elm philosophy feel free to correct me.
From my perspective, it would be good to now to not worry about how pagination happens if standard relay cursor specification is used.

So instead of handling nextPage/prevPage/finding the end and the beginning of the cursor inside my model, I'd rather have a function which I can give specific Node to and it will return PaginatedData to me.

Considering that it also needs to handle model changes it almost feels like it needs to be a separate subset on Model which would have attributes like hasNextPage/hasPrevPage/isLoading/refetch. Thinking of this a bit more in terms of Elm type safety, do you think it would be possible to generate paginator on the fly when standard relay connection detected?

@dillonkearns dillonkearns reopened this Jan 9, 2019
@dillonkearns
Copy link
Owner Author

Hello @Maxim-Filimonov! Yes, those are along the lines I was thinking as well. I took a working example of pagination and played around with turning it into a nice API that could be generated for APIs that follow the Relay Connections Spec. I'm happy with what I have so far! #113

@dillonkearns
Copy link
Owner Author

I'm going to close this issue out and let any feedback on my current design happen on #113. Any feedback is welcome there. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants