Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 4.2k
Vue: add new impertive methods to vue proxy QueryClient#11208
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
1791e59da867369a5e589b55a8f3fed8472e806f44File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@tanstack/vue-query': minor | ||
| --- | ||
| add new imperitive methods to QueryClient proxy | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -50,12 +50,13 @@ export default defineNuxtPlugin((nuxt) => { | ||
| Now you are ready to prefetch some data in your pages with `onServerPrefetch`. | ||
| - Prefetch all the queries that you need with `queryClient.prefetchQuery` or `suspense` | ||
| - Prefetch all the queries that you need with `queryClient.query`, `queryClient.infiniteQuery`, or `suspense` | ||
| ```ts | ||
| export default defineComponent({ | ||
| setup() { | ||
| const { data, suspense } = useQuery({ | ||
| const queryClient = useQueryClient() | ||
| const { data } = useQuery({ | ||
DogPawHat marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| queryKey: ['test'], | ||
| queryFn: fetcher, | ||
| }) | ||
| @@ -110,7 +111,7 @@ Now you are ready to prefetch some data in your pages with `onServerPrefetch`. | ||
| - Use `useContext` to get nuxt context | ||
| - Use `useQueryClient` to get server-side instance of `queryClient` | ||
| - Prefetch all the queries that you need with `queryClient.prefetchQuery` or `suspense` | ||
| - Prefetch all the queries that you need with `queryClient.query`, `queryClient.infiniteQuery`, or `suspense` | ||
| - Dehydrate `queryClient` to the `nuxtContext` | ||
| ```vue | ||
| @@ -169,7 +170,7 @@ export default defineComponent({ | ||
| </script> | ||
| ``` | ||
| As demonstrated, it's fine to prefetch some queries and let others fetch on the queryClient. This means you can control what content server renders or not by adding or removing `prefetchQuery` or `suspense` for a specific query. | ||
| As demonstrated, it's fine to prefetch some queries and let others fetch on the client. This means you can control what content server renders or not by adding or removing `queryClient.query` or `suspense` for a specific query. | ||
| ## Using Vite SSR | ||
| @@ -237,7 +238,7 @@ Then, call VueQuery from any component using Vue's `onServerPrefetch`: | ||
| Any query with an error is automatically excluded from dehydration. This means that the default behavior is to pretend these queries were never loaded on the server, usually showing a loading state instead, and retrying the queries on the queryClient. This happens regardless of error. | ||
| Sometimes this behavior is not desirable, maybe you want to render an error page with a correct status code instead on certain errors or queries. In those cases, use `fetchQuery` and catch any errors to handle those manually. | ||
| Sometimes this behavior is not desirable, maybe you want to render an error page with a correct status code instead on certain errors or queries. In those cases, use `queryClient.query` and catch any errors to handle those manually. | ||
| ### Staleness is measured from when the query was fetched on the server | ||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.