-
-
Notifications
You must be signed in to change notification settings - Fork 28
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
Helpers to prefetch data #91
Comments
@nopitown, thank you for the suggestion! I have not used prefetch with Tanstack before. My rough draft of how the generated code will look like and how to use it. /** generated code */
const prefetchUseFooServiceFindOne = (queryClient: QueryClient, options = {
// properties here
}) => queryClient.prefetchQuery({
queryKey: [
useFooServiceFindOnePrefetchKey,
// options
],
queryFn: () => {
return FooService.findOne({
// options
});
},
});
/** use */
const queryClient = new QueryClient({});
// using defaults
await prefetchUseFooServiceFindOne(queryClient);
// using overrides
await prefetchUseFooServiceFindOne(queryClient, {
page: 1,
limit: 10,
}); I opened a PR to start addressing this: #92 |
This looks fantastic! Let me give it a try 🙏🏼 |
Reopening as this is not released yet. @7nohe |
Sorry for the delay. v1.2.1 has been released! |
Posted something that could make the hook more useful #102 |
Is your feature request related to a problem? Please describe.
Currently, I'm prefetching data in a server component so it can later be used in a client component. But creating the code is a manual process that could be easier if we have helpers (similar to the hooks).
Describe the solution you'd like
It would be nice to have something like:
Instead of building it from scratch:
Any chance to consider this?
Describe alternatives you've considered
N/A
Additional context
I'm prefetching data using the guidelines from here
The text was updated successfully, but these errors were encountered: