-
-
Notifications
You must be signed in to change notification settings - Fork 454
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
(graphcache) - Add mergeMode to simplePagination helper #1174
(graphcache) - Add mergeMode to simplePagination helper #1174
Conversation
🦋 Changeset detectedLatest commit: 6f1231a The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Thank you for taking the time to PR this, mind adding a changeset
by running yarn changeset
at the root? This would be a minor
for @urql/exchange-graphcache
since we're adding a pagination feature! 👍
46a4b51
to
7b9b54b
Compare
Thanks for such a quick review! I added documentation for |
I believe this is misunderstanding what the I believe Furthermore I'm unsure the explanation in the RFC is accurate and whether a lot of APIs even use this pattern? Do we have some prior art here? |
@kitten You are right. I am not familiar with Relay and possibly misusing the term
This matches the description of what I am trying to achieve. Perhaps, |
@hoangvvo i believe would rename it like that 👍 the reason why the description matches is because for this paragraph it describes rather what happens when we start pagination from in reverse while forward pagination has been used and vice-versa. So the behaviour does match but it's for a subtly different reason 😅 |
I agree that it is still a somewhat uncommon pattern. I can definitely workaround this by simply reverse the returned GraphQL array appropriately.
The current Otherwise, how would you rename it? I am steering toward
|
Awesome! Yea, I think |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's one more section in the docs that needs updating, but I can totally do that after this PR myself if you'd like ✌️ https://github.com/FormidableLabs/urql/blob/main/docs/api/graphcache.md#simplepagination
Thanks for adding this!
.changeset/little-crabs-sell.md
Outdated
'@urql/exchange-graphcache': minor | ||
--- | ||
|
||
Add mergeMode = 'before' | 'after' to simplePagination helper to define whether pages are merged before or after when you paginate forwards and backwards |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add mergeMode = 'before' | 'after' to simplePagination helper to define whether pages are merged before or after when you paginate forwards and backwards | |
Add a `mergeMode: 'before' | 'after'` option to the `simplePagination` helper to define whether pages are merged before or after preceding ones when pagination, similar to `relayPagination`'s option |
Just suggesting some details here since we can use full markdown in our changelog 😇
docs/graphcache/computed-queries.md
Outdated
You can also specify `mergeMode`, which defaults to `after` and can otherwise | ||
be set to `before`. This will handle how pages are merged when you paginate |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can also specify `mergeMode`, which defaults to `after` and can otherwise | |
be set to `before`. This will handle how pages are merged when you paginate | |
We may also add the `mergeMode` option, which defaults to `'after'` and can otherwise | |
be set to `'before'`. This will handle in which order pages are merged when paginating |
We usually use "we" as often as possible when writing (with some exceptions). I realise the Graphcache pages may need some revamping to make sure they're as helpful as can be compared to some others, but let's take that into account here
Thanks for the review, I updated the documentation and also added to |
Resolves #1173
Summary
Set of changes
Adds
mergeMode
tosimplePagination
similar to that ofrelayPagination
. Default toinwards
, so it will not be a breaking change.