-
-
Notifications
You must be signed in to change notification settings - Fork 450
-
-
Notifications
You must be signed in to change notification settings - Fork 450
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
RFC: useQueries
for executing a dynamic number of queries in the same component
#2126
Comments
The problem here is the deterministic aspect, for instance we could compose this out of multiple useQuery calls but that's against the rules of hooks so the only other option we have is to open a set of streams which could get a bit of akward when updates come in. Generally this RFC seems incomplete as for instance the |
Thanks for the response. I'll try to explain my issue with graphCache's relayPagination a little bit better :) My issue is an interaction between the I have the following scenario:
Here, User A is stuck with a deleted item and refreshing the page won't help because of the With something like The rfc is currently half baked. I've only started looking into how / if |
That is an interesting scenario, I have to admit, normalized caching and lists are famously hard 😅 I would probably resort to invalidating the queries at hand by a mechanism like I do realise that |
I think ultimately we'll have to bring a first class solution to Graphcache for this, possibly, because "trains of invalidation", where a single update triggers more when writing to the cache, or validation due to refetches isn't a thing right now |
Invalidating each query individually would work for a force refresh. One of the things I like about this RFC that I'm not sure can currently be done is that I would like to display different pages when the user is coming back to a history entry (back button) VS creating a new history entry: If the user presses back and arrives back on an infinite list, I want to restore the state of that list to exactly what the user had so I can properly restore their scroll. I'd do that by storing used page variables in But for new history entries, I'd only display the first page with In both cases I don't want to refresh every page automatically (too expensive). At most, the first one. |
Sorry for coming back to this late. While it doesn't work for React Native's While I do see this as a UI concern, and While it's a tricky question, and it pains me that we haven't had time to expand on these docs for this specific issue, I'd still point at this approach today: https://formidable.com/open-source/urql/docs/basics/ui-patterns/#infinite-scrolling In short, rendering multiple components that all are responsible for one page each, rendering fragments, is a very powerful and flexible approach, and still allows invalidation, since input parameters to |
Summary
This is yet another request that relates to pagination.
As far as I know, there are currently 3 ways to handle pagination, each with their disadvantages.
Proposed Solution
A new
useQueries
hook would provide the building block for this scenario. This hook would accept an array ofUseQueryArgs
, and return an array ofUseQueryResponse
.If you need to load a new page, you simply push a new entry to the array that is passed to
useQueries
.The text was updated successfully, but these errors were encountered: