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

Open
dillonkearns opened this Issue Jan 28, 2018 · 4 comments

Comments

Projects
None yet
3 participants
@dillonkearns
Copy link
Owner

dillonkearns commented Jan 28, 2018

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

This comment has been minimized.

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

This comment has been minimized.

Copy link
Owner

dillonkearns commented Mar 9, 2018

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

@dillonkearns

This comment has been minimized.

Copy link
Owner

dillonkearns commented Aug 16, 2018

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

@Maxim-Filimonov

This comment has been minimized.

Copy link

Maxim-Filimonov commented Jan 5, 2019

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

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