Skip to content
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

Preload queries #6

Open
posva opened this issue Feb 19, 2024 — with Volta.net · 3 comments
Open

Preload queries #6

posva opened this issue Feb 19, 2024 — with Volta.net · 3 comments
Labels
✨ feature request a new feature request

Comments

Copy link
Owner

posva commented Feb 19, 2024

Allowing a query to be preloaded
Requires all the options rather than just the key as otherwise it might not exist

@posva posva added the ✨ feature request a new feature request label Mar 6, 2024 — with Volta.net
@quiteeasy
Copy link
Contributor

Is preloading a query the same as instantiating the query before user navigation? The key difference should be allowing preloading in user actions (e.g., click, hover, etc.) and in lifecycle hooks. Should we introduce another API, like usePreloadQuery, specifically for this purpose?

@posva
Copy link
Owner Author

posva commented May 28, 2024

it is about instantiating the query. It doesn't have to be about navigation but it should integrate easily into that too. I'm not sure if a new API is needed yet. The idea is to have:

  • A way to ensure the entry (should be good)
  • A method that can load the entry and return a promise

So maybe this is just a matter of documentation at this point. Not sure yet

@posva
Copy link
Owner Author

posva commented Nov 5, 2024

Currently doable with

const queryCache = useQueryCache()
queryCache.setQueryData(['the key'], await fetchData())

Depending on the staleTime, the data will be fresh and calling refresh() won't get it again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ feature request a new feature request
Projects
Status: Todo
Development

No branches or pull requests

2 participants