-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Update infinite query draft PR to separate PageParams
type
#4674
Draft
markerikson
wants to merge
31
commits into
master
Choose a base branch
from
feature/infinite-query-pageparams
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…uerying will happen
…of args and forward/backwards direction
…Page functions + Thunk
This reverts commit 4089f11
Review or Edit in CodeSandboxOpen the branch in Web Editor • VS Code • Insiders |
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 3f0b35f:
|
✅ Deploy Preview for redux-starter-kit-docs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
size-limit report 📦
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is a copy of the "Infinite Query API" draft PR in #4393 , but with (currently) one additional commit that tries to modify the infinite query endpoint definitions to add a separate
PageParam
TS generic and pass it through:Background
With the current implementation in #4393, the
QueryArg
type gets used as the type for thepageParam
field. That results in an awkward usage pattern, because there's a conflation between "the arg we use to generate the cache key" vs "the value we need to define the next page to fetch".What I think we want is to specify
builder.infiniteQuery<ReturnType, QueryArg, PageParam>()
. What we should end up with is a cached data structure of{pages: ReturnType[], pageParams: PageParam[]}
.We also should then override the normal query endpoint types so that we end up with
query: (arg: PageParam)
, but keep the external behavior ofinitiate(arg: QueryArg)
.I could be wrong on all this, but this seems like it makes sense to my admittedly-confused brain.
Current WIP
In 3f0b35f , I've successfully threaded a
PageParam
generic through all the layers of our endpoint definitions. Where I'm stuck is getting that split behavior between the type of arg ininitiate()
vs the type of arg inquery()
.In
infiniteQueries.test.tsx
, I have this example code:It looks like the behavior is ultimately controlled by our
BaseEndpointDefinition
type. The existing implementation is:I've tried three other variations, each of which fails in a different way:
(I had to reconstruct those types by hand in this PR description - I probably made a typo somewhere, but hopefully it's clear what I'm going for)