prisma-relay-cursor-connection
prisma-relay-cursor-connection copied to clipboard
Support pageCursors for pagination with links to pages
From the end-user's code it is not possible to implement a user-interface like:
Without effectively re-creating this library (or drastically over-fetching).
Back at the start of last year, @mzikherman gave a write-up on a technique used at Artsy to support cursor connections with pages: https://artsy.github.io/blog/2020/01/21/graphql-relay-windowed-pagination/ this PR implements that technique and the only difference for an end user is changing findManyCursorConnection to findManyCursorConnectionWithPageCursors.
I've marked it as a draft because there's a few bugs still left to remove on my side, but I thought it was worth presenting this (big) PR early so I can get feedback on whether it's something you want in here?
Thank you for the pull request!
I won't have time till around next week to have a look at the code, but I thought I'd leave this comment to say that functionality wise I'd be very happy to get this in. 👍
References #339
Cool, great.
No worries, I won't be using this work till the weekend realistically
I'm getting close now:
- I've merged #367 here because I'm spending so much time in snapshots
- The JSON responses when you are making paginated requests are correct, as are the pageInfos
- Just need to make sure going backwards works and that non paginated cursor requests still work the same
OK, this should be good
Codecov Report
Merging #366 (9a272ca) into master (f1c2988) will decrease coverage by
3.07%. The diff coverage is94.44%.
@@ Coverage Diff @@
## master #366 +/- ##
===========================================
- Coverage 100.00% 96.92% -3.08%
===========================================
Files 2 3 +1
Lines 64 130 +66
Branches 18 39 +21
===========================================
+ Hits 64 126 +62
- Misses 0 4 +4
| Impacted Files | Coverage Δ | |
|---|---|---|
| src/pageCursorsHelpers.ts | 88.23% <88.23%> (ø) |
|
| src/index.ts | 100.00% <100.00%> (ø) |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing dataPowered by Codecov. Last update f1c2988...9a272ca. Read the comment docs.
Just checking in to say I'd still be happy to get this in - let me know if there's any support needed :)
Hah, yeah, funny story - I needed to prove this could all work before I got started with prisma, but so far haven't needed to actually use it in my app yet!
So, I've not had the chance to go back through your feedback and try to handle those changes - you're welcome to giv eit a shot, otherwise I'll get around to it at some point (because I'll need it)
Would also be interested to have page cursors. Another implementation I found interesting is described here https://medium.com/@smallbee/super-fast-offset-pagination-with-prisma2-21db93e5cc90 and here https://github.com/prisma-korea/prisma-offset-pagination
Since this PR has been open without movement for a while and is now also conflicting, I'll be closing it. I have moved the idea of adding support for this to #541. If anyone is interested in adding this, please have a look at the conversation & review comments here and I'll be happy to merge another PR.