-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
feat(ensureQueryData): add 'revalidateIfStale' option #6996
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Ignored Deployment
|
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 90aa502:
|
☁️ Nx Cloud ReportCI is running/has finished running commands for commit 90aa502. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this CI Pipeline Execution ✅ Successfully ran 2 targetsSent with 💌 from NxCloud. |
Thanks for this. I thought about it for some time, and while I think there are ways to combine I think the better API would be to add this option to
what's missing is the piece in between: data exists, but is stale. I think we could just add a Since your use-case is also router related, and we recommend using |
alright that also makes sense, i added it to But |
can you also add some tests for this please ? |
Will do |
Test added. At first the test needs to return cached data which is 'old', we wait for the promise to resolve which will let the new call return 'new' |
please fix prettier |
@TkDodo For me it seems like the build is not build properly. in ensureQueryData<TQueryFnData, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(options: FetchQueryOptions<TQueryFnData, TError, TData, TQueryKey>): Promise<TData>;
ensureQueryData<TQueryFnData, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(options: MaybeRefDeep<FetchQueryOptions<TQueryFnData, TError, TData, TQueryKey>>): Promise<TData>; where it should be ensureQueryData<TQueryFnData, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(options: EnsureQueryDataOptions<TQueryFnData, TError, TData, TQueryKey>): Promise<TData>;
ensureQueryData<TQueryFnData, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(options: MaybeRefDeep<EnsureQueryDataOptions<TQueryFnData, TError, TData, TQueryKey>>): Promise<TData>; |
its inside the vue-query plugin, not in core |
ooh, that's because query/packages/vue-query/src/queryClient.ts Lines 87 to 98 in 61f4d74
can you do another PR to fix this please ? |
A alright, yes will do. |
add a prefetchWhenStale property to the fetchQuery function.
This allows the function to work like useQuery.
As discussed here: https://discord.com/channels/719702312431386674/1212427380912820315
Please feel free to give feedback about how to better implement this feature.