@tanstack/vue-query 5.103.2 → 5.103.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (202) hide show
  1. package/build/legacy/devtools/devtools.d.cts +1 -1
  2. package/build/legacy/devtools/devtools.d.ts +1 -1
  3. package/build/legacy/devtools/utils.d.cts.map +1 -1
  4. package/build/legacy/devtools/utils.d.ts.map +1 -1
  5. package/build/legacy/index.d.cts +3 -3
  6. package/build/legacy/index.d.ts +3 -3
  7. package/build/legacy/{infiniteQueryOptions-qN6sOJM-.d.cts → infiniteQueryOptions-CnTRbIP5.d.cts} +16 -6
  8. package/build/legacy/infiniteQueryOptions-CnTRbIP5.d.cts.map +1 -0
  9. package/build/legacy/{infiniteQueryOptions-CEDiLwh5.d.ts → infiniteQueryOptions-NucMX_M_.d.ts} +16 -6
  10. package/build/legacy/infiniteQueryOptions-NucMX_M_.d.ts.map +1 -0
  11. package/build/legacy/infiniteQueryOptions.cjs.map +1 -1
  12. package/build/legacy/infiniteQueryOptions.d.cts +1 -1
  13. package/build/legacy/infiniteQueryOptions.d.ts +1 -1
  14. package/build/legacy/infiniteQueryOptions.js.map +1 -1
  15. package/build/legacy/mutationCache.d.cts.map +1 -1
  16. package/build/legacy/mutationCache.d.ts.map +1 -1
  17. package/build/legacy/mutationOptions.cjs.map +1 -1
  18. package/build/legacy/mutationOptions.d.cts +4 -0
  19. package/build/legacy/mutationOptions.d.cts.map +1 -1
  20. package/build/legacy/mutationOptions.d.ts +4 -0
  21. package/build/legacy/mutationOptions.d.ts.map +1 -1
  22. package/build/legacy/mutationOptions.js.map +1 -1
  23. package/build/legacy/queryCache.d.cts.map +1 -1
  24. package/build/legacy/queryCache.d.ts.map +1 -1
  25. package/build/legacy/{queryClient-Cv73nzNT.d.ts → queryClient-B6mLtXOj.d.ts} +9 -2
  26. package/build/legacy/queryClient-B6mLtXOj.d.ts.map +1 -0
  27. package/build/{modern/queryClient-CZeNAt68.d.cts → legacy/queryClient-Bn2Ql_Lu.d.cts} +9 -2
  28. package/build/legacy/queryClient-Bn2Ql_Lu.d.cts.map +1 -0
  29. package/build/legacy/queryClient.cjs +7 -0
  30. package/build/legacy/queryClient.cjs.map +1 -1
  31. package/build/legacy/queryClient.d.cts +1 -1
  32. package/build/legacy/queryClient.d.ts +1 -1
  33. package/build/legacy/queryClient.js +7 -0
  34. package/build/legacy/queryClient.js.map +1 -1
  35. package/build/{modern/queryOptions-DPDwdVBu.d.ts → legacy/queryOptions-CsM5TXD2.d.ts} +4 -3
  36. package/build/legacy/queryOptions-CsM5TXD2.d.ts.map +1 -0
  37. package/build/{modern/queryOptions-rkZ3sk6g.d.cts → legacy/queryOptions-CwqQgQmQ.d.cts} +4 -3
  38. package/build/legacy/queryOptions-CwqQgQmQ.d.cts.map +1 -0
  39. package/build/legacy/queryOptions.cjs.map +1 -1
  40. package/build/legacy/queryOptions.d.cts +1 -1
  41. package/build/legacy/queryOptions.d.ts +1 -1
  42. package/build/legacy/queryOptions.js.map +1 -1
  43. package/build/legacy/types-JpJB72CS.d.cts.map +1 -1
  44. package/build/legacy/types-JpJB72CS.d.ts.map +1 -1
  45. package/build/legacy/useBaseQuery.cjs.map +1 -1
  46. package/build/legacy/useBaseQuery.d.cts +1 -1
  47. package/build/legacy/useBaseQuery.d.ts +1 -1
  48. package/build/legacy/useBaseQuery.js.map +1 -1
  49. package/build/legacy/useInfiniteQuery.cjs.map +1 -1
  50. package/build/legacy/useInfiniteQuery.d.cts +1 -1
  51. package/build/legacy/useInfiniteQuery.d.ts +1 -1
  52. package/build/legacy/useInfiniteQuery.js.map +1 -1
  53. package/build/legacy/useIsFetching.cjs.map +1 -1
  54. package/build/legacy/useIsFetching.d.cts +1 -1
  55. package/build/legacy/useIsFetching.d.cts.map +1 -1
  56. package/build/legacy/useIsFetching.d.ts +1 -1
  57. package/build/legacy/useIsFetching.d.ts.map +1 -1
  58. package/build/legacy/useIsFetching.js.map +1 -1
  59. package/build/legacy/useMutation.d.cts +1 -1
  60. package/build/legacy/useMutation.d.cts.map +1 -1
  61. package/build/legacy/useMutation.d.ts +1 -1
  62. package/build/legacy/useMutation.d.ts.map +1 -1
  63. package/build/legacy/useMutationState.cjs.map +1 -1
  64. package/build/legacy/useMutationState.d.cts +1 -1
  65. package/build/legacy/useMutationState.d.cts.map +1 -1
  66. package/build/legacy/useMutationState.d.ts +1 -1
  67. package/build/legacy/useMutationState.d.ts.map +1 -1
  68. package/build/legacy/useMutationState.js.map +1 -1
  69. package/build/legacy/usePrefetchInfiniteQuery.d.cts +1 -1
  70. package/build/legacy/usePrefetchInfiniteQuery.d.cts.map +1 -1
  71. package/build/legacy/usePrefetchInfiniteQuery.d.ts +1 -1
  72. package/build/legacy/usePrefetchInfiniteQuery.d.ts.map +1 -1
  73. package/build/legacy/usePrefetchQuery.d.cts +1 -1
  74. package/build/legacy/usePrefetchQuery.d.cts.map +1 -1
  75. package/build/legacy/usePrefetchQuery.d.ts +1 -1
  76. package/build/legacy/usePrefetchQuery.d.ts.map +1 -1
  77. package/build/legacy/useQueries.d.cts +2 -2
  78. package/build/legacy/useQueries.d.cts.map +1 -1
  79. package/build/legacy/useQueries.d.ts +2 -2
  80. package/build/legacy/useQueries.d.ts.map +1 -1
  81. package/build/legacy/useQuery.cjs.map +1 -1
  82. package/build/legacy/useQuery.d.cts +13 -7
  83. package/build/legacy/useQuery.d.cts.map +1 -1
  84. package/build/legacy/useQuery.d.ts +13 -7
  85. package/build/legacy/useQuery.d.ts.map +1 -1
  86. package/build/legacy/useQuery.js.map +1 -1
  87. package/build/legacy/useQueryClient.d.cts +1 -1
  88. package/build/legacy/useQueryClient.d.ts +1 -1
  89. package/build/legacy/vueQueryPlugin.d.cts +1 -1
  90. package/build/legacy/vueQueryPlugin.d.ts +1 -1
  91. package/build/modern/devtools/devtools.d.cts +1 -1
  92. package/build/modern/devtools/devtools.d.ts +1 -1
  93. package/build/modern/devtools/utils.d.cts.map +1 -1
  94. package/build/modern/devtools/utils.d.ts.map +1 -1
  95. package/build/modern/index.d.cts +3 -3
  96. package/build/modern/index.d.ts +3 -3
  97. package/build/modern/{infiniteQueryOptions-qN6sOJM-.d.cts → infiniteQueryOptions-CnTRbIP5.d.cts} +16 -6
  98. package/build/modern/infiniteQueryOptions-CnTRbIP5.d.cts.map +1 -0
  99. package/build/modern/{infiniteQueryOptions-CEDiLwh5.d.ts → infiniteQueryOptions-NucMX_M_.d.ts} +16 -6
  100. package/build/modern/infiniteQueryOptions-NucMX_M_.d.ts.map +1 -0
  101. package/build/modern/infiniteQueryOptions.cjs.map +1 -1
  102. package/build/modern/infiniteQueryOptions.d.cts +1 -1
  103. package/build/modern/infiniteQueryOptions.d.ts +1 -1
  104. package/build/modern/infiniteQueryOptions.js.map +1 -1
  105. package/build/modern/mutationCache.d.cts.map +1 -1
  106. package/build/modern/mutationCache.d.ts.map +1 -1
  107. package/build/modern/mutationOptions.cjs.map +1 -1
  108. package/build/modern/mutationOptions.d.cts +4 -0
  109. package/build/modern/mutationOptions.d.cts.map +1 -1
  110. package/build/modern/mutationOptions.d.ts +4 -0
  111. package/build/modern/mutationOptions.d.ts.map +1 -1
  112. package/build/modern/mutationOptions.js.map +1 -1
  113. package/build/modern/queryCache.d.cts.map +1 -1
  114. package/build/modern/queryCache.d.ts.map +1 -1
  115. package/build/modern/{queryClient-Cv73nzNT.d.ts → queryClient-B6mLtXOj.d.ts} +9 -2
  116. package/build/modern/queryClient-B6mLtXOj.d.ts.map +1 -0
  117. package/build/{legacy/queryClient-CZeNAt68.d.cts → modern/queryClient-Bn2Ql_Lu.d.cts} +9 -2
  118. package/build/modern/queryClient-Bn2Ql_Lu.d.cts.map +1 -0
  119. package/build/modern/queryClient.cjs +7 -0
  120. package/build/modern/queryClient.cjs.map +1 -1
  121. package/build/modern/queryClient.d.cts +1 -1
  122. package/build/modern/queryClient.d.ts +1 -1
  123. package/build/modern/queryClient.js +7 -0
  124. package/build/modern/queryClient.js.map +1 -1
  125. package/build/{legacy/queryOptions-DPDwdVBu.d.ts → modern/queryOptions-CsM5TXD2.d.ts} +4 -3
  126. package/build/modern/queryOptions-CsM5TXD2.d.ts.map +1 -0
  127. package/build/{legacy/queryOptions-rkZ3sk6g.d.cts → modern/queryOptions-CwqQgQmQ.d.cts} +4 -3
  128. package/build/modern/queryOptions-CwqQgQmQ.d.cts.map +1 -0
  129. package/build/modern/queryOptions.cjs.map +1 -1
  130. package/build/modern/queryOptions.d.cts +1 -1
  131. package/build/modern/queryOptions.d.ts +1 -1
  132. package/build/modern/queryOptions.js.map +1 -1
  133. package/build/modern/types-JpJB72CS.d.cts.map +1 -1
  134. package/build/modern/types-JpJB72CS.d.ts.map +1 -1
  135. package/build/modern/useBaseQuery.cjs.map +1 -1
  136. package/build/modern/useBaseQuery.d.cts +1 -1
  137. package/build/modern/useBaseQuery.d.ts +1 -1
  138. package/build/modern/useBaseQuery.js.map +1 -1
  139. package/build/modern/useInfiniteQuery.cjs.map +1 -1
  140. package/build/modern/useInfiniteQuery.d.cts +1 -1
  141. package/build/modern/useInfiniteQuery.d.ts +1 -1
  142. package/build/modern/useInfiniteQuery.js.map +1 -1
  143. package/build/modern/useIsFetching.cjs.map +1 -1
  144. package/build/modern/useIsFetching.d.cts +1 -1
  145. package/build/modern/useIsFetching.d.cts.map +1 -1
  146. package/build/modern/useIsFetching.d.ts +1 -1
  147. package/build/modern/useIsFetching.d.ts.map +1 -1
  148. package/build/modern/useIsFetching.js.map +1 -1
  149. package/build/modern/useMutation.d.cts +1 -1
  150. package/build/modern/useMutation.d.cts.map +1 -1
  151. package/build/modern/useMutation.d.ts +1 -1
  152. package/build/modern/useMutation.d.ts.map +1 -1
  153. package/build/modern/useMutationState.cjs.map +1 -1
  154. package/build/modern/useMutationState.d.cts +1 -1
  155. package/build/modern/useMutationState.d.cts.map +1 -1
  156. package/build/modern/useMutationState.d.ts +1 -1
  157. package/build/modern/useMutationState.d.ts.map +1 -1
  158. package/build/modern/useMutationState.js.map +1 -1
  159. package/build/modern/usePrefetchInfiniteQuery.d.cts +1 -1
  160. package/build/modern/usePrefetchInfiniteQuery.d.cts.map +1 -1
  161. package/build/modern/usePrefetchInfiniteQuery.d.ts +1 -1
  162. package/build/modern/usePrefetchInfiniteQuery.d.ts.map +1 -1
  163. package/build/modern/usePrefetchQuery.d.cts +1 -1
  164. package/build/modern/usePrefetchQuery.d.cts.map +1 -1
  165. package/build/modern/usePrefetchQuery.d.ts +1 -1
  166. package/build/modern/usePrefetchQuery.d.ts.map +1 -1
  167. package/build/modern/useQueries.d.cts +2 -2
  168. package/build/modern/useQueries.d.cts.map +1 -1
  169. package/build/modern/useQueries.d.ts +2 -2
  170. package/build/modern/useQueries.d.ts.map +1 -1
  171. package/build/modern/useQuery.cjs.map +1 -1
  172. package/build/modern/useQuery.d.cts +13 -7
  173. package/build/modern/useQuery.d.cts.map +1 -1
  174. package/build/modern/useQuery.d.ts +13 -7
  175. package/build/modern/useQuery.d.ts.map +1 -1
  176. package/build/modern/useQuery.js.map +1 -1
  177. package/build/modern/useQueryClient.d.cts +1 -1
  178. package/build/modern/useQueryClient.d.ts +1 -1
  179. package/build/modern/vueQueryPlugin.d.cts +1 -1
  180. package/build/modern/vueQueryPlugin.d.ts +1 -1
  181. package/package.json +8 -8
  182. package/src/infiniteQueryOptions.ts +3 -2
  183. package/src/mutationOptions.ts +4 -0
  184. package/src/queryClient.ts +7 -0
  185. package/src/queryOptions.ts +29 -26
  186. package/src/useBaseQuery.ts +9 -3
  187. package/src/useInfiniteQuery.ts +11 -8
  188. package/src/useIsFetching.ts +1 -2
  189. package/src/useMutationState.ts +1 -2
  190. package/src/useQuery.ts +11 -6
  191. package/build/legacy/infiniteQueryOptions-CEDiLwh5.d.ts.map +0 -1
  192. package/build/legacy/infiniteQueryOptions-qN6sOJM-.d.cts.map +0 -1
  193. package/build/legacy/queryClient-CZeNAt68.d.cts.map +0 -1
  194. package/build/legacy/queryClient-Cv73nzNT.d.ts.map +0 -1
  195. package/build/legacy/queryOptions-DPDwdVBu.d.ts.map +0 -1
  196. package/build/legacy/queryOptions-rkZ3sk6g.d.cts.map +0 -1
  197. package/build/modern/infiniteQueryOptions-CEDiLwh5.d.ts.map +0 -1
  198. package/build/modern/infiniteQueryOptions-qN6sOJM-.d.cts.map +0 -1
  199. package/build/modern/queryClient-CZeNAt68.d.cts.map +0 -1
  200. package/build/modern/queryClient-Cv73nzNT.d.ts.map +0 -1
  201. package/build/modern/queryOptions-DPDwdVBu.d.ts.map +0 -1
  202. package/build/modern/queryOptions-rkZ3sk6g.d.cts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"useQuery.cjs","names":["useBaseQuery","QueryObserver"],"sources":["../../src/useQuery.ts"],"sourcesContent":["import { QueryObserver } from '@tanstack/query-core'\nimport { useBaseQuery } from './useBaseQuery'\nimport type {\n DefaultError,\n DefinedQueryObserverResult,\n QueryKey,\n} from '@tanstack/query-core'\nimport type { UseBaseQueryReturnType } from './useBaseQuery'\nimport type { MaybeRefOrGetter } from './types'\nimport type { QueryClient } from './queryClient'\nimport type {\n DefinedInitialQueryOptions,\n UndefinedInitialQueryOptions,\n UseQueryOptions,\n} from './queryOptions'\n\nexport type UseQueryReturnType<TData, TError> = UseBaseQueryReturnType<\n TData,\n TError\n>\n\nexport type UseQueryDefinedReturnType<TData, TError> = UseBaseQueryReturnType<\n TData,\n TError,\n DefinedQueryObserverResult<TData, TError>\n>\n\n/**\n * This overload is selected when `initialData` is set, so the resulting `data` is never `undefined`.\n *\n * `enabled` tracks reactive dependencies automatically as a `ref`, a plain value, or a reactive getter\n * (`() => ...`). `queryKey` reacts through a `ref` or a reactive getter for the array itself, or `ref`s and\n * reactive getters as individual entries. Other options are read once when passed as a plain value, and stay\n * reactive when passed as a `ref` or a `computed`.\n *\n * @param options - The {@link DefinedInitialQueryOptions} to use — everything you can pass to `useQuery`, with\n * `initialData` set.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`\n * will be used.\n * @returns The current query result, typed so that `data` is never `undefined` (`status` never resolves to\n * `pending` in this overload's type, since `initialData` guarantees data upfront).\n *\n * @example\n * ```vue\n * <script setup lang=\"ts\">\n * import { useQuery } from '@tanstack/vue-query'\n *\n * // `data` is `Post[]`, never `undefined`, thanks to `initialData` — even if a refetch fails,\n * // so the list stays visible alongside the error.\n * const { data, isError, error } = useQuery({\n * queryKey: ['posts'],\n * queryFn: fetchPosts,\n * initialData: [],\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"isError\">Error: {{ error.message }}</span>\n * <ul>\n * <li v-for=\"post in data\" :key=\"post.id\">{{ post.title }}</li>\n * </ul>\n * </template>\n * ```\n */\nexport function useQuery<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: DefinedInitialQueryOptions<TQueryFnData, TError, TData, TQueryKey>,\n queryClient?: QueryClient,\n): UseQueryDefinedReturnType<TData, TError>\n\n/**\n * `enabled` tracks reactive dependencies automatically as a `ref`, a plain value, or a reactive getter\n * (`() => ...`). `queryKey` reacts through a `ref` or a reactive getter for the array itself, or `ref`s and\n * reactive getters as individual entries. Other options are read once when passed as a plain value, and stay\n * reactive when passed as a `ref` or a `computed`.\n *\n * @param options - The {@link UndefinedInitialQueryOptions} to use — everything you can pass to `useQuery`.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`\n * will be used.\n * @returns The current query result. `status` is `pending` if there is no cached data to display, `error` if\n * the last fetch attempt failed, or `success` if the query has data to display.\n *\n * @example\n * A query key built from a reactive `ref` — the query refetches whenever `postId` changes:\n * ```vue\n * <script setup lang=\"ts\">\n * import { ref } from 'vue'\n * import { useQuery } from '@tanstack/vue-query'\n *\n * const postId = ref(1)\n * const { status, data, error } = useQuery({\n * queryKey: ['post', postId],\n * queryFn: () => fetchPost(postId.value),\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"status === 'pending'\">Loading...</span>\n * <span v-else-if=\"status === 'error'\">Error: {{ error.message }}</span>\n * <h1 v-else>{{ data.title }}</h1>\n * </template>\n * ```\n *\n * @example\n * `select` derives whatever `data` a component needs from the cached value, without changing what's\n * actually stored in the cache — the cache still holds the full `Post[]`, but `data` here is a `number`:\n * ```vue\n * <script setup lang=\"ts\">\n * import { useQuery } from '@tanstack/vue-query'\n *\n * const { data, isPending, isError, error } = useQuery({\n * queryKey: ['posts'],\n * queryFn: fetchPosts,\n * select: (posts) => posts.length,\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"isPending\">Loading...</span>\n * <span v-else-if=\"isError\">Error: {{ error.message }}</span>\n * <span v-else>{{ data }} posts</span>\n * </template>\n * ```\n *\n * @example\n * A dependent query, only enabled once `postId` is set — use `isLoading`, not `isPending`, so the\n * loading state doesn't show while the query is disabled:\n * ```vue\n * <script setup lang=\"ts\">\n * import { ref } from 'vue'\n * import { useQuery } from '@tanstack/vue-query'\n *\n * const props = defineProps<{ postId: number | undefined }>()\n *\n * const { data, isLoading, isError, error } = useQuery({\n * queryKey: ['post', props.postId],\n * queryFn: () => fetchPost(props.postId!),\n * enabled: () => props.postId != null,\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"props.postId == null\">Select a post</span>\n * <span v-else-if=\"isLoading\">Loading...</span>\n * <span v-else-if=\"isError\">Error: {{ error.message }}</span>\n * <h1 v-else>{{ data?.title }}</h1>\n * </template>\n * ```\n *\n * @example\n * Seeding a detail query from an already-cached list, to skip the loading state:\n * ```vue\n * <script setup lang=\"ts\">\n * import { useQuery, useQueryClient } from '@tanstack/vue-query'\n *\n * const props = defineProps<{ postId: number }>()\n * const queryClient = useQueryClient()\n *\n * const { data, isError, error } = useQuery({\n * queryKey: ['post', props.postId],\n * queryFn: () => fetchPost(props.postId),\n * initialData: () =>\n * queryClient\n * .getQueryData<Array<Post>>(['posts'])\n * ?.find((post) => post.id === props.postId),\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"isError\">Error: {{ error.message }}</span>\n * <h1 v-else>{{ data?.title }}</h1>\n * </template>\n * ```\n *\n * @example\n * Paginated data, keeping the previous page's data visible while the next page loads:\n * ```vue\n * <script setup lang=\"ts\">\n * import { ref } from 'vue'\n * import { keepPreviousData, useQuery } from '@tanstack/vue-query'\n *\n * const page = ref(0)\n *\n * const { data, isPlaceholderData, isError, error } = useQuery({\n * queryKey: ['posts', page],\n * queryFn: () => fetchPosts(page.value),\n * placeholderData: keepPreviousData,\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"isError\">Error: {{ error.message }}</span>\n * <template v-else>\n * <ul>\n * <li v-for=\"post in data\" :key=\"post.id\">{{ post.title }}</li>\n * </ul>\n * <button :disabled=\"isPlaceholderData\" @click=\"page++\">Next Page</button>\n * </template>\n * </template>\n * ```\n */\nexport function useQuery<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: UndefinedInitialQueryOptions<TQueryFnData, TError, TData, TQueryKey>,\n queryClient?: QueryClient,\n): UseQueryReturnType<TData, TError>\n\n/**\n * Fallback overload for options whose `initialData` presence isn't statically known — for example, a\n * `ref`/reactive object built up conditionally, rather than a plain object literal. Prefer one of the other\n * overloads when possible, since they infer whether `data` can be `undefined` from `initialData` directly.\n *\n * `enabled` tracks reactive dependencies automatically as a `ref`, a plain value, or a reactive getter\n * (`() => ...`). `queryKey` reacts through a `ref` or a reactive getter for the array itself, or `ref`s and\n * reactive getters as individual entries.\n *\n * When `options` itself is a reactive getter, the whole object is re-evaluated on every change to its\n * dependencies, so any option inside it — not just `queryKey` and `enabled` — can change over time.\n *\n * @param options - A `ref`, plain value, or reactive getter resolving to the {@link UseQueryOptions} to use.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`\n * will be used.\n * @returns The current query result, with `data` typed as possibly `undefined`.\n *\n * @example\n * Passing a whole-options getter so `staleTime` reacts to a setting stored elsewhere, not just `queryKey`:\n * ```vue\n * <script setup lang=\"ts\">\n * import { useQuery } from '@tanstack/vue-query'\n *\n * const props = defineProps<{ id: number; staleTime: number }>()\n *\n * const { data } = useQuery(() => ({\n * queryKey: ['post', props.id],\n * queryFn: () => fetchPost(props.id),\n * staleTime: props.staleTime,\n * }))\n * </script>\n *\n * <template>\n * <h1 v-if=\"data\">{{ data.title }}</h1>\n * </template>\n * ```\n *\n * @example\n * `skipToken` disables the query in a type-safe way, without a non-null assertion on `props.postId` —\n * `queryFn` is only ever called when it's defined. The whole-options getter re-evaluates `queryFn` on every\n * change to `props.postId`. `queryFn` can also be a `computed`, but never a bare getter, since a function\n * there is the query function itself. `refetch` doesn't work while `queryFn` is `skipToken` — use\n * `enabled: false` instead if you need to trigger the query manually:\n * ```vue\n * <script setup lang=\"ts\">\n * import { skipToken, useQuery } from '@tanstack/vue-query'\n *\n * const props = defineProps<{ postId: number | undefined }>()\n *\n * const { data, isLoading, isError, error } = useQuery(() => {\n * const postId = props.postId\n * return {\n * queryKey: ['post', postId],\n * queryFn: postId != null ? () => fetchPost(postId) : skipToken,\n * }\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"props.postId == null\">Select a post</span>\n * <span v-else-if=\"isLoading\">Loading...</span>\n * <span v-else-if=\"isError\">Error: {{ error.message }}</span>\n * <h1 v-else>{{ data?.title }}</h1>\n * </template>\n * ```\n */\nexport function useQuery<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: MaybeRefOrGetter<\n UseQueryOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey>\n >,\n queryClient?: QueryClient,\n): UseQueryReturnType<TData, TError>\n\nexport function useQuery<\n TQueryFnData,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: MaybeRefOrGetter<\n UseQueryOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey>\n >,\n queryClient?: QueryClient,\n):\n | UseQueryReturnType<TData, TError>\n | UseQueryDefinedReturnType<TData, TError> {\n return useBaseQuery(QueryObserver, options, queryClient)\n}\n"],"mappings":";;;;AAqSA,SAAgB,SAMd,SAGA,aAG2C;CAC3C,OAAOA,qBAAAA,aAAaC,qBAAAA,eAAe,SAAS,WAAW;AACzD"}
1
+ {"version":3,"file":"useQuery.cjs","names":["useBaseQuery","QueryObserver"],"sources":["../../src/useQuery.ts"],"sourcesContent":["import { QueryObserver } from '@tanstack/query-core'\nimport { useBaseQuery } from './useBaseQuery'\nimport type {\n DefaultError,\n DefinedQueryObserverResult,\n QueryKey,\n} from '@tanstack/query-core'\nimport type { UseBaseQueryReturnType } from './useBaseQuery'\nimport type { MaybeRefOrGetter } from './types'\nimport type { QueryClient } from './queryClient'\nimport type {\n DefinedInitialQueryOptions,\n UndefinedInitialQueryOptions,\n UseQueryOptions,\n} from './queryOptions'\n\nexport type UseQueryReturnType<TData, TError> = UseBaseQueryReturnType<\n TData,\n TError\n>\n\nexport type UseQueryDefinedReturnType<TData, TError> = UseBaseQueryReturnType<\n TData,\n TError,\n DefinedQueryObserverResult<TData, TError>\n>\n\n/**\n * This overload is selected when `initialData` is set, so the resulting `data` is never `undefined` (unless\n * a `select` changes `TData` to include `undefined`).\n *\n * `enabled` tracks reactive dependencies automatically as a `ref`, a plain value, or a reactive getter\n * (`() => ...`). `queryKey` reacts through a `ref` or a reactive getter for the array itself, or `ref`s and\n * reactive getters as individual entries. Other options are read once when passed as a plain value, and stay\n * reactive when passed as a `ref` or a `computed`.\n *\n * @param options - The {@link DefinedInitialQueryOptions} to use — everything you can pass to `useQuery`, with\n * `initialData` set.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`\n * will be used.\n * @returns The current query result, typed so that `data` is never `undefined` (unless a `select` changes\n * `TData` to include `undefined`). `status` never resolves to `pending` in this overload's type, since\n * `initialData` guarantees data upfront.\n *\n * @example\n * ```vue\n * <script setup lang=\"ts\">\n * import { useQuery } from '@tanstack/vue-query'\n *\n * // `data` is `Post[]`, never `undefined`, thanks to `initialData` — even if a refetch fails,\n * // so the list stays visible alongside the error.\n * const { data, isError, error } = useQuery({\n * queryKey: ['posts'],\n * queryFn: fetchPosts,\n * initialData: [],\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"isError\">Error: {{ error.message }}</span>\n * <ul>\n * <li v-for=\"post in data\" :key=\"post.id\">{{ post.title }}</li>\n * </ul>\n * </template>\n * ```\n */\nexport function useQuery<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: DefinedInitialQueryOptions<TQueryFnData, TError, TData, TQueryKey>,\n queryClient?: QueryClient,\n): UseQueryDefinedReturnType<TData, TError>\n\n/**\n * `enabled` tracks reactive dependencies automatically as a `ref`, a plain value, or a reactive getter\n * (`() => ...`). `queryKey` reacts through a `ref` or a reactive getter for the array itself, or `ref`s and\n * reactive getters as individual entries. Other options are read once when passed as a plain value, and stay\n * reactive when passed as a `ref` or a `computed`.\n *\n * @param options - The {@link UndefinedInitialQueryOptions} to use — everything you can pass to `useQuery`.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`\n * will be used.\n * @returns The current query result. `status` is `pending` if there is no cached data to display, `error` if\n * the last fetch attempt failed, or `success` if the query has data to display.\n *\n * @example\n * A query key built from a reactive `ref` — the query refetches whenever `postId` changes:\n * ```vue\n * <script setup lang=\"ts\">\n * import { ref } from 'vue'\n * import { useQuery } from '@tanstack/vue-query'\n *\n * const postId = ref(1)\n * const { status, data, error } = useQuery({\n * queryKey: ['post', postId],\n * queryFn: () => fetchPost(postId.value),\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"status === 'pending'\">Loading...</span>\n * <span v-else-if=\"status === 'error'\">Error: {{ error.message }}</span>\n * <h1 v-else>{{ data.title }}</h1>\n * </template>\n * ```\n *\n * @example\n * `select` derives whatever `data` a component needs from the cached value, without changing what's\n * actually stored in the cache — the cache still holds the full `Post[]`, but `data` here is a `number`:\n * ```vue\n * <script setup lang=\"ts\">\n * import { useQuery } from '@tanstack/vue-query'\n *\n * const { data, isPending, isError, error } = useQuery({\n * queryKey: ['posts'],\n * queryFn: fetchPosts,\n * select: (posts) => posts.length,\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"isPending\">Loading...</span>\n * <span v-else-if=\"isError\">Error: {{ error.message }}</span>\n * <span v-else>{{ data }} posts</span>\n * </template>\n * ```\n *\n * @example\n * A dependent query, only enabled once `postId` is set — use `isLoading`, not `isPending`, so the\n * loading state doesn't show while the query is disabled:\n * ```vue\n * <script setup lang=\"ts\">\n * import { ref } from 'vue'\n * import { useQuery } from '@tanstack/vue-query'\n *\n * const props = defineProps<{ postId: number | undefined }>()\n *\n * const { data, isLoading, isError, error } = useQuery({\n * queryKey: ['post', props.postId],\n * queryFn: () => fetchPost(props.postId!),\n * enabled: () => props.postId != null,\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"props.postId == null\">Select a post</span>\n * <span v-else-if=\"isLoading\">Loading...</span>\n * <span v-else-if=\"isError\">Error: {{ error.message }}</span>\n * <h1 v-else>{{ data?.title }}</h1>\n * </template>\n * ```\n *\n * @example\n * Seeding a detail query from an already-cached list, to skip the loading state. `initialDataUpdatedAt` carries\n * over the list's own fetch time, so that if you set a `staleTime`, it's measured from when the list was\n * fetched rather than from now:\n * ```vue\n * <script setup lang=\"ts\">\n * import { useQuery, useQueryClient } from '@tanstack/vue-query'\n *\n * const props = defineProps<{ postId: number }>()\n * const queryClient = useQueryClient()\n *\n * const { data, isError, error } = useQuery({\n * queryKey: ['post', props.postId],\n * queryFn: () => fetchPost(props.postId),\n * initialData: () =>\n * queryClient\n * .getQueryData<Array<Post>>(['posts'])\n * ?.find((post) => post.id === props.postId),\n * initialDataUpdatedAt: () =>\n * queryClient.getQueryState(['posts'])?.dataUpdatedAt,\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"isError\">Error: {{ error.message }}</span>\n * <h1 v-else>{{ data?.title }}</h1>\n * </template>\n * ```\n *\n * @example\n * Paginated data, keeping the previous page's data visible while the next page loads:\n * ```vue\n * <script setup lang=\"ts\">\n * import { ref } from 'vue'\n * import { keepPreviousData, useQuery } from '@tanstack/vue-query'\n *\n * const page = ref(0)\n *\n * const { data, isPlaceholderData, isError, error } = useQuery({\n * queryKey: ['posts', page],\n * queryFn: () => fetchPosts(page.value),\n * placeholderData: keepPreviousData,\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"isError\">Error: {{ error.message }}</span>\n * <template v-else>\n * <ul>\n * <li v-for=\"post in data\" :key=\"post.id\">{{ post.title }}</li>\n * </ul>\n * <button :disabled=\"isPlaceholderData\" @click=\"page++\">Next Page</button>\n * </template>\n * </template>\n * ```\n */\nexport function useQuery<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: UndefinedInitialQueryOptions<TQueryFnData, TError, TData, TQueryKey>,\n queryClient?: QueryClient,\n): UseQueryReturnType<TData, TError>\n\n/**\n * Fallback overload for options whose `initialData` presence isn't statically known — for example, a\n * `ref`/reactive object built up conditionally, rather than a plain object literal. Prefer one of the other\n * overloads when possible, since they infer whether `data` can be `undefined` from `initialData` directly.\n *\n * `enabled` tracks reactive dependencies automatically as a `ref`, a plain value, or a reactive getter\n * (`() => ...`). `queryKey` reacts through a `ref` or a reactive getter for the array itself, or `ref`s and\n * reactive getters as individual entries.\n *\n * When `options` itself is a reactive getter, the whole object is re-evaluated on every change to its\n * dependencies, so any option inside it — not just `queryKey` and `enabled` — can change over time.\n *\n * @param options - A `ref`, plain value, or reactive getter resolving to the {@link UseQueryOptions} to use.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`\n * will be used.\n * @returns The current query result, with `data` typed as possibly `undefined`.\n *\n * @example\n * Passing a whole-options getter so `staleTime` reacts to a setting stored elsewhere, not just `queryKey`:\n * ```vue\n * <script setup lang=\"ts\">\n * import { useQuery } from '@tanstack/vue-query'\n *\n * const props = defineProps<{ id: number; staleTime: number }>()\n *\n * const { data } = useQuery(() => ({\n * queryKey: ['post', props.id],\n * queryFn: () => fetchPost(props.id),\n * staleTime: props.staleTime,\n * }))\n * </script>\n *\n * <template>\n * <h1 v-if=\"data\">{{ data.title }}</h1>\n * </template>\n * ```\n *\n * @example\n * `skipToken` disables the query in a type-safe way, without a non-null assertion on `props.postId` —\n * `queryFn` is only ever called when it's defined. The whole-options getter re-evaluates `queryFn` on every\n * change to `props.postId`. `queryFn` can also be a `computed`, but never a bare getter, since a function\n * there is the query function itself. `refetch` doesn't work while `queryFn` is `skipToken` — use\n * `enabled: false` instead if you need to trigger the query manually:\n * ```vue\n * <script setup lang=\"ts\">\n * import { skipToken, useQuery } from '@tanstack/vue-query'\n *\n * const props = defineProps<{ postId: number | undefined }>()\n *\n * const { data, isLoading, isError, error } = useQuery(() => {\n * const postId = props.postId\n * return {\n * queryKey: ['post', postId],\n * queryFn: postId != null ? () => fetchPost(postId) : skipToken,\n * }\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"props.postId == null\">Select a post</span>\n * <span v-else-if=\"isLoading\">Loading...</span>\n * <span v-else-if=\"isError\">Error: {{ error.message }}</span>\n * <h1 v-else>{{ data?.title }}</h1>\n * </template>\n * ```\n */\nexport function useQuery<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: MaybeRefOrGetter<\n UseQueryOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey>\n >,\n queryClient?: QueryClient,\n): UseQueryReturnType<TData, TError>\n\nexport function useQuery<\n TQueryFnData,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: MaybeRefOrGetter<\n UseQueryOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey>\n >,\n queryClient?: QueryClient,\n):\n UseQueryReturnType<TData, TError> | UseQueryDefinedReturnType<TData, TError> {\n return useBaseQuery(QueryObserver, options, queryClient)\n}\n"],"mappings":";;;;AA2SA,SAAgB,SAMd,SAGA,aAE6E;CAC7E,OAAOA,qBAAAA,aAAaC,qBAAAA,eAAe,SAAS,WAAW;AACzD"}
@@ -1,13 +1,14 @@
1
1
  import { s as MaybeRefOrGetter } from "./types-JpJB72CS.cjs";
2
- import { i as UndefinedInitialQueryOptions, o as UseQueryOptions, t as DefinedInitialQueryOptions } from "./queryOptions-rkZ3sk6g.cjs";
3
- import { t as QueryClient$1 } from "./queryClient-CZeNAt68.cjs";
4
- import { s as UseBaseQueryReturnType } from "./infiniteQueryOptions-qN6sOJM-.cjs";
2
+ import { i as UndefinedInitialQueryOptions, o as UseQueryOptions, t as DefinedInitialQueryOptions } from "./queryOptions-CwqQgQmQ.cjs";
3
+ import { t as QueryClient$1 } from "./queryClient-Bn2Ql_Lu.cjs";
4
+ import { s as UseBaseQueryReturnType } from "./infiniteQueryOptions-CnTRbIP5.cjs";
5
5
  import { DefaultError, DefinedQueryObserverResult, QueryKey } from "@tanstack/query-core";
6
6
  //#region src/useQuery.d.ts
7
7
  type UseQueryReturnType<TData, TError> = UseBaseQueryReturnType<TData, TError>;
8
8
  type UseQueryDefinedReturnType<TData, TError> = UseBaseQueryReturnType<TData, TError, DefinedQueryObserverResult<TData, TError>>;
9
9
  /**
10
- * This overload is selected when `initialData` is set, so the resulting `data` is never `undefined`.
10
+ * This overload is selected when `initialData` is set, so the resulting `data` is never `undefined` (unless
11
+ * a `select` changes `TData` to include `undefined`).
11
12
  *
12
13
  * `enabled` tracks reactive dependencies automatically as a `ref`, a plain value, or a reactive getter
13
14
  * (`() => ...`). `queryKey` reacts through a `ref` or a reactive getter for the array itself, or `ref`s and
@@ -18,8 +19,9 @@ type UseQueryDefinedReturnType<TData, TError> = UseBaseQueryReturnType<TData, TE
18
19
  * `initialData` set.
19
20
  * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`
20
21
  * will be used.
21
- * @returns The current query result, typed so that `data` is never `undefined` (`status` never resolves to
22
- * `pending` in this overload's type, since `initialData` guarantees data upfront).
22
+ * @returns The current query result, typed so that `data` is never `undefined` (unless a `select` changes
23
+ * `TData` to include `undefined`). `status` never resolves to `pending` in this overload's type, since
24
+ * `initialData` guarantees data upfront.
23
25
  *
24
26
  * @example
25
27
  * ```vue
@@ -124,7 +126,9 @@ declare function useQuery<TQueryFnData = unknown, TError = DefaultError, TData =
124
126
  * ```
125
127
  *
126
128
  * @example
127
- * Seeding a detail query from an already-cached list, to skip the loading state:
129
+ * Seeding a detail query from an already-cached list, to skip the loading state. `initialDataUpdatedAt` carries
130
+ * over the list's own fetch time, so that if you set a `staleTime`, it's measured from when the list was
131
+ * fetched rather than from now:
128
132
  * ```vue
129
133
  * <script setup lang="ts">
130
134
  * import { useQuery, useQueryClient } from '@tanstack/vue-query'
@@ -139,6 +143,8 @@ declare function useQuery<TQueryFnData = unknown, TError = DefaultError, TData =
139
143
  * queryClient
140
144
  * .getQueryData<Array<Post>>(['posts'])
141
145
  * ?.find((post) => post.id === props.postId),
146
+ * initialDataUpdatedAt: () =>
147
+ * queryClient.getQueryState(['posts'])?.dataUpdatedAt,
142
148
  * })
143
149
  * </script>
144
150
  *
@@ -1 +1 @@
1
- {"version":3,"file":"useQuery.d.cts","names":[],"sources":["../../src/useQuery.ts"],"mappings":";;;;;;KAgBY,mBAAmB,OAAO,UAAU,uBAC9C,OACA;KAGU,0BAA0B,OAAO,UAAU,uBACrD,OACA,QACA,2BAA2B,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAwCpB,SACd,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,UAE7B,SAAS,2BAA2B,cAAc,QAAQ,OAAO,YACjE,cAAc,gBACb,0BAA0B,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAqIpB,SACd,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,UAE7B,SAAS,6BAA6B,cAAc,QAAQ,OAAO,YACnE,cAAc,gBACb,mBAAmB,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAoEb,SACd,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,UAE7B,SAAS,iBACP,gBAAgB,cAAc,QAAQ,OAAO,cAAc,aAE7D,cAAc,gBACb,mBAAmB,OAAO"}
1
+ {"version":3,"file":"useQuery.d.cts","names":["QueryClient"],"sources":["../../src/useQuery.ts"],"mappings":";;;;;;KAgBY,mBAAmB,OAAO,UAAU,uBAC9C,OACA;KAGU,0BAA0B,OAAO,UAAU,uBACrD,OACA,QACA,2BAA2B,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA0CpB,SACd,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,UAE7B,SAAS,2BAA2B,cAAc,QAAQ,OAAO,YACjE,cAAcA,gBACb,0BAA0B,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAyIpB,SACd,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,UAE7B,SAAS,6BAA6B,cAAc,QAAQ,OAAO,YACnE,cAAcA,gBACb,mBAAmB,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAoEb,SACd,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,UAE7B,SAAS,iBACP,gBAAgB,cAAc,QAAQ,OAAO,cAAc,aAE7D,cAAcA,gBACb,mBAAmB,OAAO"}
@@ -1,13 +1,14 @@
1
1
  import { s as MaybeRefOrGetter } from "./types-JpJB72CS.js";
2
- import { i as UndefinedInitialQueryOptions, o as UseQueryOptions, t as DefinedInitialQueryOptions } from "./queryOptions-DPDwdVBu.js";
3
- import { t as QueryClient$1 } from "./queryClient-Cv73nzNT.js";
4
- import { s as UseBaseQueryReturnType } from "./infiniteQueryOptions-CEDiLwh5.js";
2
+ import { i as UndefinedInitialQueryOptions, o as UseQueryOptions, t as DefinedInitialQueryOptions } from "./queryOptions-CsM5TXD2.js";
3
+ import { t as QueryClient$1 } from "./queryClient-B6mLtXOj.js";
4
+ import { s as UseBaseQueryReturnType } from "./infiniteQueryOptions-NucMX_M_.js";
5
5
  import { DefaultError, DefinedQueryObserverResult, QueryKey } from "@tanstack/query-core";
6
6
  //#region src/useQuery.d.ts
7
7
  type UseQueryReturnType<TData, TError> = UseBaseQueryReturnType<TData, TError>;
8
8
  type UseQueryDefinedReturnType<TData, TError> = UseBaseQueryReturnType<TData, TError, DefinedQueryObserverResult<TData, TError>>;
9
9
  /**
10
- * This overload is selected when `initialData` is set, so the resulting `data` is never `undefined`.
10
+ * This overload is selected when `initialData` is set, so the resulting `data` is never `undefined` (unless
11
+ * a `select` changes `TData` to include `undefined`).
11
12
  *
12
13
  * `enabled` tracks reactive dependencies automatically as a `ref`, a plain value, or a reactive getter
13
14
  * (`() => ...`). `queryKey` reacts through a `ref` or a reactive getter for the array itself, or `ref`s and
@@ -18,8 +19,9 @@ type UseQueryDefinedReturnType<TData, TError> = UseBaseQueryReturnType<TData, TE
18
19
  * `initialData` set.
19
20
  * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`
20
21
  * will be used.
21
- * @returns The current query result, typed so that `data` is never `undefined` (`status` never resolves to
22
- * `pending` in this overload's type, since `initialData` guarantees data upfront).
22
+ * @returns The current query result, typed so that `data` is never `undefined` (unless a `select` changes
23
+ * `TData` to include `undefined`). `status` never resolves to `pending` in this overload's type, since
24
+ * `initialData` guarantees data upfront.
23
25
  *
24
26
  * @example
25
27
  * ```vue
@@ -124,7 +126,9 @@ declare function useQuery<TQueryFnData = unknown, TError = DefaultError, TData =
124
126
  * ```
125
127
  *
126
128
  * @example
127
- * Seeding a detail query from an already-cached list, to skip the loading state:
129
+ * Seeding a detail query from an already-cached list, to skip the loading state. `initialDataUpdatedAt` carries
130
+ * over the list's own fetch time, so that if you set a `staleTime`, it's measured from when the list was
131
+ * fetched rather than from now:
128
132
  * ```vue
129
133
  * <script setup lang="ts">
130
134
  * import { useQuery, useQueryClient } from '@tanstack/vue-query'
@@ -139,6 +143,8 @@ declare function useQuery<TQueryFnData = unknown, TError = DefaultError, TData =
139
143
  * queryClient
140
144
  * .getQueryData<Array<Post>>(['posts'])
141
145
  * ?.find((post) => post.id === props.postId),
146
+ * initialDataUpdatedAt: () =>
147
+ * queryClient.getQueryState(['posts'])?.dataUpdatedAt,
142
148
  * })
143
149
  * </script>
144
150
  *
@@ -1 +1 @@
1
- {"version":3,"file":"useQuery.d.ts","names":[],"sources":["../../src/useQuery.ts"],"mappings":";;;;;;KAgBY,mBAAmB,OAAO,UAAU,uBAC9C,OACA;KAGU,0BAA0B,OAAO,UAAU,uBACrD,OACA,QACA,2BAA2B,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAwCpB,SACd,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,UAE7B,SAAS,2BAA2B,cAAc,QAAQ,OAAO,YACjE,cAAc,gBACb,0BAA0B,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAqIpB,SACd,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,UAE7B,SAAS,6BAA6B,cAAc,QAAQ,OAAO,YACnE,cAAc,gBACb,mBAAmB,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAoEb,SACd,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,UAE7B,SAAS,iBACP,gBAAgB,cAAc,QAAQ,OAAO,cAAc,aAE7D,cAAc,gBACb,mBAAmB,OAAO"}
1
+ {"version":3,"file":"useQuery.d.ts","names":["QueryClient"],"sources":["../../src/useQuery.ts"],"mappings":";;;;;;KAgBY,mBAAmB,OAAO,UAAU,uBAC9C,OACA;KAGU,0BAA0B,OAAO,UAAU,uBACrD,OACA,QACA,2BAA2B,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA0CpB,SACd,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,UAE7B,SAAS,2BAA2B,cAAc,QAAQ,OAAO,YACjE,cAAcA,gBACb,0BAA0B,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAyIpB,SACd,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,UAE7B,SAAS,6BAA6B,cAAc,QAAQ,OAAO,YACnE,cAAcA,gBACb,mBAAmB,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAoEb,SACd,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,UAE7B,SAAS,iBACP,gBAAgB,cAAc,QAAQ,OAAO,cAAc,aAE7D,cAAcA,gBACb,mBAAmB,OAAO"}
@@ -1 +1 @@
1
- {"version":3,"file":"useQuery.js","names":[],"sources":["../../src/useQuery.ts"],"sourcesContent":["import { QueryObserver } from '@tanstack/query-core'\nimport { useBaseQuery } from './useBaseQuery'\nimport type {\n DefaultError,\n DefinedQueryObserverResult,\n QueryKey,\n} from '@tanstack/query-core'\nimport type { UseBaseQueryReturnType } from './useBaseQuery'\nimport type { MaybeRefOrGetter } from './types'\nimport type { QueryClient } from './queryClient'\nimport type {\n DefinedInitialQueryOptions,\n UndefinedInitialQueryOptions,\n UseQueryOptions,\n} from './queryOptions'\n\nexport type UseQueryReturnType<TData, TError> = UseBaseQueryReturnType<\n TData,\n TError\n>\n\nexport type UseQueryDefinedReturnType<TData, TError> = UseBaseQueryReturnType<\n TData,\n TError,\n DefinedQueryObserverResult<TData, TError>\n>\n\n/**\n * This overload is selected when `initialData` is set, so the resulting `data` is never `undefined`.\n *\n * `enabled` tracks reactive dependencies automatically as a `ref`, a plain value, or a reactive getter\n * (`() => ...`). `queryKey` reacts through a `ref` or a reactive getter for the array itself, or `ref`s and\n * reactive getters as individual entries. Other options are read once when passed as a plain value, and stay\n * reactive when passed as a `ref` or a `computed`.\n *\n * @param options - The {@link DefinedInitialQueryOptions} to use — everything you can pass to `useQuery`, with\n * `initialData` set.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`\n * will be used.\n * @returns The current query result, typed so that `data` is never `undefined` (`status` never resolves to\n * `pending` in this overload's type, since `initialData` guarantees data upfront).\n *\n * @example\n * ```vue\n * <script setup lang=\"ts\">\n * import { useQuery } from '@tanstack/vue-query'\n *\n * // `data` is `Post[]`, never `undefined`, thanks to `initialData` — even if a refetch fails,\n * // so the list stays visible alongside the error.\n * const { data, isError, error } = useQuery({\n * queryKey: ['posts'],\n * queryFn: fetchPosts,\n * initialData: [],\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"isError\">Error: {{ error.message }}</span>\n * <ul>\n * <li v-for=\"post in data\" :key=\"post.id\">{{ post.title }}</li>\n * </ul>\n * </template>\n * ```\n */\nexport function useQuery<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: DefinedInitialQueryOptions<TQueryFnData, TError, TData, TQueryKey>,\n queryClient?: QueryClient,\n): UseQueryDefinedReturnType<TData, TError>\n\n/**\n * `enabled` tracks reactive dependencies automatically as a `ref`, a plain value, or a reactive getter\n * (`() => ...`). `queryKey` reacts through a `ref` or a reactive getter for the array itself, or `ref`s and\n * reactive getters as individual entries. Other options are read once when passed as a plain value, and stay\n * reactive when passed as a `ref` or a `computed`.\n *\n * @param options - The {@link UndefinedInitialQueryOptions} to use — everything you can pass to `useQuery`.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`\n * will be used.\n * @returns The current query result. `status` is `pending` if there is no cached data to display, `error` if\n * the last fetch attempt failed, or `success` if the query has data to display.\n *\n * @example\n * A query key built from a reactive `ref` — the query refetches whenever `postId` changes:\n * ```vue\n * <script setup lang=\"ts\">\n * import { ref } from 'vue'\n * import { useQuery } from '@tanstack/vue-query'\n *\n * const postId = ref(1)\n * const { status, data, error } = useQuery({\n * queryKey: ['post', postId],\n * queryFn: () => fetchPost(postId.value),\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"status === 'pending'\">Loading...</span>\n * <span v-else-if=\"status === 'error'\">Error: {{ error.message }}</span>\n * <h1 v-else>{{ data.title }}</h1>\n * </template>\n * ```\n *\n * @example\n * `select` derives whatever `data` a component needs from the cached value, without changing what's\n * actually stored in the cache — the cache still holds the full `Post[]`, but `data` here is a `number`:\n * ```vue\n * <script setup lang=\"ts\">\n * import { useQuery } from '@tanstack/vue-query'\n *\n * const { data, isPending, isError, error } = useQuery({\n * queryKey: ['posts'],\n * queryFn: fetchPosts,\n * select: (posts) => posts.length,\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"isPending\">Loading...</span>\n * <span v-else-if=\"isError\">Error: {{ error.message }}</span>\n * <span v-else>{{ data }} posts</span>\n * </template>\n * ```\n *\n * @example\n * A dependent query, only enabled once `postId` is set — use `isLoading`, not `isPending`, so the\n * loading state doesn't show while the query is disabled:\n * ```vue\n * <script setup lang=\"ts\">\n * import { ref } from 'vue'\n * import { useQuery } from '@tanstack/vue-query'\n *\n * const props = defineProps<{ postId: number | undefined }>()\n *\n * const { data, isLoading, isError, error } = useQuery({\n * queryKey: ['post', props.postId],\n * queryFn: () => fetchPost(props.postId!),\n * enabled: () => props.postId != null,\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"props.postId == null\">Select a post</span>\n * <span v-else-if=\"isLoading\">Loading...</span>\n * <span v-else-if=\"isError\">Error: {{ error.message }}</span>\n * <h1 v-else>{{ data?.title }}</h1>\n * </template>\n * ```\n *\n * @example\n * Seeding a detail query from an already-cached list, to skip the loading state:\n * ```vue\n * <script setup lang=\"ts\">\n * import { useQuery, useQueryClient } from '@tanstack/vue-query'\n *\n * const props = defineProps<{ postId: number }>()\n * const queryClient = useQueryClient()\n *\n * const { data, isError, error } = useQuery({\n * queryKey: ['post', props.postId],\n * queryFn: () => fetchPost(props.postId),\n * initialData: () =>\n * queryClient\n * .getQueryData<Array<Post>>(['posts'])\n * ?.find((post) => post.id === props.postId),\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"isError\">Error: {{ error.message }}</span>\n * <h1 v-else>{{ data?.title }}</h1>\n * </template>\n * ```\n *\n * @example\n * Paginated data, keeping the previous page's data visible while the next page loads:\n * ```vue\n * <script setup lang=\"ts\">\n * import { ref } from 'vue'\n * import { keepPreviousData, useQuery } from '@tanstack/vue-query'\n *\n * const page = ref(0)\n *\n * const { data, isPlaceholderData, isError, error } = useQuery({\n * queryKey: ['posts', page],\n * queryFn: () => fetchPosts(page.value),\n * placeholderData: keepPreviousData,\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"isError\">Error: {{ error.message }}</span>\n * <template v-else>\n * <ul>\n * <li v-for=\"post in data\" :key=\"post.id\">{{ post.title }}</li>\n * </ul>\n * <button :disabled=\"isPlaceholderData\" @click=\"page++\">Next Page</button>\n * </template>\n * </template>\n * ```\n */\nexport function useQuery<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: UndefinedInitialQueryOptions<TQueryFnData, TError, TData, TQueryKey>,\n queryClient?: QueryClient,\n): UseQueryReturnType<TData, TError>\n\n/**\n * Fallback overload for options whose `initialData` presence isn't statically known — for example, a\n * `ref`/reactive object built up conditionally, rather than a plain object literal. Prefer one of the other\n * overloads when possible, since they infer whether `data` can be `undefined` from `initialData` directly.\n *\n * `enabled` tracks reactive dependencies automatically as a `ref`, a plain value, or a reactive getter\n * (`() => ...`). `queryKey` reacts through a `ref` or a reactive getter for the array itself, or `ref`s and\n * reactive getters as individual entries.\n *\n * When `options` itself is a reactive getter, the whole object is re-evaluated on every change to its\n * dependencies, so any option inside it — not just `queryKey` and `enabled` — can change over time.\n *\n * @param options - A `ref`, plain value, or reactive getter resolving to the {@link UseQueryOptions} to use.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`\n * will be used.\n * @returns The current query result, with `data` typed as possibly `undefined`.\n *\n * @example\n * Passing a whole-options getter so `staleTime` reacts to a setting stored elsewhere, not just `queryKey`:\n * ```vue\n * <script setup lang=\"ts\">\n * import { useQuery } from '@tanstack/vue-query'\n *\n * const props = defineProps<{ id: number; staleTime: number }>()\n *\n * const { data } = useQuery(() => ({\n * queryKey: ['post', props.id],\n * queryFn: () => fetchPost(props.id),\n * staleTime: props.staleTime,\n * }))\n * </script>\n *\n * <template>\n * <h1 v-if=\"data\">{{ data.title }}</h1>\n * </template>\n * ```\n *\n * @example\n * `skipToken` disables the query in a type-safe way, without a non-null assertion on `props.postId` —\n * `queryFn` is only ever called when it's defined. The whole-options getter re-evaluates `queryFn` on every\n * change to `props.postId`. `queryFn` can also be a `computed`, but never a bare getter, since a function\n * there is the query function itself. `refetch` doesn't work while `queryFn` is `skipToken` — use\n * `enabled: false` instead if you need to trigger the query manually:\n * ```vue\n * <script setup lang=\"ts\">\n * import { skipToken, useQuery } from '@tanstack/vue-query'\n *\n * const props = defineProps<{ postId: number | undefined }>()\n *\n * const { data, isLoading, isError, error } = useQuery(() => {\n * const postId = props.postId\n * return {\n * queryKey: ['post', postId],\n * queryFn: postId != null ? () => fetchPost(postId) : skipToken,\n * }\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"props.postId == null\">Select a post</span>\n * <span v-else-if=\"isLoading\">Loading...</span>\n * <span v-else-if=\"isError\">Error: {{ error.message }}</span>\n * <h1 v-else>{{ data?.title }}</h1>\n * </template>\n * ```\n */\nexport function useQuery<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: MaybeRefOrGetter<\n UseQueryOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey>\n >,\n queryClient?: QueryClient,\n): UseQueryReturnType<TData, TError>\n\nexport function useQuery<\n TQueryFnData,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: MaybeRefOrGetter<\n UseQueryOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey>\n >,\n queryClient?: QueryClient,\n):\n | UseQueryReturnType<TData, TError>\n | UseQueryDefinedReturnType<TData, TError> {\n return useBaseQuery(QueryObserver, options, queryClient)\n}\n"],"mappings":";;;AAqSA,SAAgB,SAMd,SAGA,aAG2C;CAC3C,OAAO,aAAa,eAAe,SAAS,WAAW;AACzD"}
1
+ {"version":3,"file":"useQuery.js","names":[],"sources":["../../src/useQuery.ts"],"sourcesContent":["import { QueryObserver } from '@tanstack/query-core'\nimport { useBaseQuery } from './useBaseQuery'\nimport type {\n DefaultError,\n DefinedQueryObserverResult,\n QueryKey,\n} from '@tanstack/query-core'\nimport type { UseBaseQueryReturnType } from './useBaseQuery'\nimport type { MaybeRefOrGetter } from './types'\nimport type { QueryClient } from './queryClient'\nimport type {\n DefinedInitialQueryOptions,\n UndefinedInitialQueryOptions,\n UseQueryOptions,\n} from './queryOptions'\n\nexport type UseQueryReturnType<TData, TError> = UseBaseQueryReturnType<\n TData,\n TError\n>\n\nexport type UseQueryDefinedReturnType<TData, TError> = UseBaseQueryReturnType<\n TData,\n TError,\n DefinedQueryObserverResult<TData, TError>\n>\n\n/**\n * This overload is selected when `initialData` is set, so the resulting `data` is never `undefined` (unless\n * a `select` changes `TData` to include `undefined`).\n *\n * `enabled` tracks reactive dependencies automatically as a `ref`, a plain value, or a reactive getter\n * (`() => ...`). `queryKey` reacts through a `ref` or a reactive getter for the array itself, or `ref`s and\n * reactive getters as individual entries. Other options are read once when passed as a plain value, and stay\n * reactive when passed as a `ref` or a `computed`.\n *\n * @param options - The {@link DefinedInitialQueryOptions} to use — everything you can pass to `useQuery`, with\n * `initialData` set.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`\n * will be used.\n * @returns The current query result, typed so that `data` is never `undefined` (unless a `select` changes\n * `TData` to include `undefined`). `status` never resolves to `pending` in this overload's type, since\n * `initialData` guarantees data upfront.\n *\n * @example\n * ```vue\n * <script setup lang=\"ts\">\n * import { useQuery } from '@tanstack/vue-query'\n *\n * // `data` is `Post[]`, never `undefined`, thanks to `initialData` — even if a refetch fails,\n * // so the list stays visible alongside the error.\n * const { data, isError, error } = useQuery({\n * queryKey: ['posts'],\n * queryFn: fetchPosts,\n * initialData: [],\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"isError\">Error: {{ error.message }}</span>\n * <ul>\n * <li v-for=\"post in data\" :key=\"post.id\">{{ post.title }}</li>\n * </ul>\n * </template>\n * ```\n */\nexport function useQuery<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: DefinedInitialQueryOptions<TQueryFnData, TError, TData, TQueryKey>,\n queryClient?: QueryClient,\n): UseQueryDefinedReturnType<TData, TError>\n\n/**\n * `enabled` tracks reactive dependencies automatically as a `ref`, a plain value, or a reactive getter\n * (`() => ...`). `queryKey` reacts through a `ref` or a reactive getter for the array itself, or `ref`s and\n * reactive getters as individual entries. Other options are read once when passed as a plain value, and stay\n * reactive when passed as a `ref` or a `computed`.\n *\n * @param options - The {@link UndefinedInitialQueryOptions} to use — everything you can pass to `useQuery`.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`\n * will be used.\n * @returns The current query result. `status` is `pending` if there is no cached data to display, `error` if\n * the last fetch attempt failed, or `success` if the query has data to display.\n *\n * @example\n * A query key built from a reactive `ref` — the query refetches whenever `postId` changes:\n * ```vue\n * <script setup lang=\"ts\">\n * import { ref } from 'vue'\n * import { useQuery } from '@tanstack/vue-query'\n *\n * const postId = ref(1)\n * const { status, data, error } = useQuery({\n * queryKey: ['post', postId],\n * queryFn: () => fetchPost(postId.value),\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"status === 'pending'\">Loading...</span>\n * <span v-else-if=\"status === 'error'\">Error: {{ error.message }}</span>\n * <h1 v-else>{{ data.title }}</h1>\n * </template>\n * ```\n *\n * @example\n * `select` derives whatever `data` a component needs from the cached value, without changing what's\n * actually stored in the cache — the cache still holds the full `Post[]`, but `data` here is a `number`:\n * ```vue\n * <script setup lang=\"ts\">\n * import { useQuery } from '@tanstack/vue-query'\n *\n * const { data, isPending, isError, error } = useQuery({\n * queryKey: ['posts'],\n * queryFn: fetchPosts,\n * select: (posts) => posts.length,\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"isPending\">Loading...</span>\n * <span v-else-if=\"isError\">Error: {{ error.message }}</span>\n * <span v-else>{{ data }} posts</span>\n * </template>\n * ```\n *\n * @example\n * A dependent query, only enabled once `postId` is set — use `isLoading`, not `isPending`, so the\n * loading state doesn't show while the query is disabled:\n * ```vue\n * <script setup lang=\"ts\">\n * import { ref } from 'vue'\n * import { useQuery } from '@tanstack/vue-query'\n *\n * const props = defineProps<{ postId: number | undefined }>()\n *\n * const { data, isLoading, isError, error } = useQuery({\n * queryKey: ['post', props.postId],\n * queryFn: () => fetchPost(props.postId!),\n * enabled: () => props.postId != null,\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"props.postId == null\">Select a post</span>\n * <span v-else-if=\"isLoading\">Loading...</span>\n * <span v-else-if=\"isError\">Error: {{ error.message }}</span>\n * <h1 v-else>{{ data?.title }}</h1>\n * </template>\n * ```\n *\n * @example\n * Seeding a detail query from an already-cached list, to skip the loading state. `initialDataUpdatedAt` carries\n * over the list's own fetch time, so that if you set a `staleTime`, it's measured from when the list was\n * fetched rather than from now:\n * ```vue\n * <script setup lang=\"ts\">\n * import { useQuery, useQueryClient } from '@tanstack/vue-query'\n *\n * const props = defineProps<{ postId: number }>()\n * const queryClient = useQueryClient()\n *\n * const { data, isError, error } = useQuery({\n * queryKey: ['post', props.postId],\n * queryFn: () => fetchPost(props.postId),\n * initialData: () =>\n * queryClient\n * .getQueryData<Array<Post>>(['posts'])\n * ?.find((post) => post.id === props.postId),\n * initialDataUpdatedAt: () =>\n * queryClient.getQueryState(['posts'])?.dataUpdatedAt,\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"isError\">Error: {{ error.message }}</span>\n * <h1 v-else>{{ data?.title }}</h1>\n * </template>\n * ```\n *\n * @example\n * Paginated data, keeping the previous page's data visible while the next page loads:\n * ```vue\n * <script setup lang=\"ts\">\n * import { ref } from 'vue'\n * import { keepPreviousData, useQuery } from '@tanstack/vue-query'\n *\n * const page = ref(0)\n *\n * const { data, isPlaceholderData, isError, error } = useQuery({\n * queryKey: ['posts', page],\n * queryFn: () => fetchPosts(page.value),\n * placeholderData: keepPreviousData,\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"isError\">Error: {{ error.message }}</span>\n * <template v-else>\n * <ul>\n * <li v-for=\"post in data\" :key=\"post.id\">{{ post.title }}</li>\n * </ul>\n * <button :disabled=\"isPlaceholderData\" @click=\"page++\">Next Page</button>\n * </template>\n * </template>\n * ```\n */\nexport function useQuery<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: UndefinedInitialQueryOptions<TQueryFnData, TError, TData, TQueryKey>,\n queryClient?: QueryClient,\n): UseQueryReturnType<TData, TError>\n\n/**\n * Fallback overload for options whose `initialData` presence isn't statically known — for example, a\n * `ref`/reactive object built up conditionally, rather than a plain object literal. Prefer one of the other\n * overloads when possible, since they infer whether `data` can be `undefined` from `initialData` directly.\n *\n * `enabled` tracks reactive dependencies automatically as a `ref`, a plain value, or a reactive getter\n * (`() => ...`). `queryKey` reacts through a `ref` or a reactive getter for the array itself, or `ref`s and\n * reactive getters as individual entries.\n *\n * When `options` itself is a reactive getter, the whole object is re-evaluated on every change to its\n * dependencies, so any option inside it — not just `queryKey` and `enabled` — can change over time.\n *\n * @param options - A `ref`, plain value, or reactive getter resolving to the {@link UseQueryOptions} to use.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`\n * will be used.\n * @returns The current query result, with `data` typed as possibly `undefined`.\n *\n * @example\n * Passing a whole-options getter so `staleTime` reacts to a setting stored elsewhere, not just `queryKey`:\n * ```vue\n * <script setup lang=\"ts\">\n * import { useQuery } from '@tanstack/vue-query'\n *\n * const props = defineProps<{ id: number; staleTime: number }>()\n *\n * const { data } = useQuery(() => ({\n * queryKey: ['post', props.id],\n * queryFn: () => fetchPost(props.id),\n * staleTime: props.staleTime,\n * }))\n * </script>\n *\n * <template>\n * <h1 v-if=\"data\">{{ data.title }}</h1>\n * </template>\n * ```\n *\n * @example\n * `skipToken` disables the query in a type-safe way, without a non-null assertion on `props.postId` —\n * `queryFn` is only ever called when it's defined. The whole-options getter re-evaluates `queryFn` on every\n * change to `props.postId`. `queryFn` can also be a `computed`, but never a bare getter, since a function\n * there is the query function itself. `refetch` doesn't work while `queryFn` is `skipToken` — use\n * `enabled: false` instead if you need to trigger the query manually:\n * ```vue\n * <script setup lang=\"ts\">\n * import { skipToken, useQuery } from '@tanstack/vue-query'\n *\n * const props = defineProps<{ postId: number | undefined }>()\n *\n * const { data, isLoading, isError, error } = useQuery(() => {\n * const postId = props.postId\n * return {\n * queryKey: ['post', postId],\n * queryFn: postId != null ? () => fetchPost(postId) : skipToken,\n * }\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"props.postId == null\">Select a post</span>\n * <span v-else-if=\"isLoading\">Loading...</span>\n * <span v-else-if=\"isError\">Error: {{ error.message }}</span>\n * <h1 v-else>{{ data?.title }}</h1>\n * </template>\n * ```\n */\nexport function useQuery<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: MaybeRefOrGetter<\n UseQueryOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey>\n >,\n queryClient?: QueryClient,\n): UseQueryReturnType<TData, TError>\n\nexport function useQuery<\n TQueryFnData,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: MaybeRefOrGetter<\n UseQueryOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey>\n >,\n queryClient?: QueryClient,\n):\n UseQueryReturnType<TData, TError> | UseQueryDefinedReturnType<TData, TError> {\n return useBaseQuery(QueryObserver, options, queryClient)\n}\n"],"mappings":";;;AA2SA,SAAgB,SAMd,SAGA,aAE6E;CAC7E,OAAO,aAAa,eAAe,SAAS,WAAW;AACzD"}
@@ -1,4 +1,4 @@
1
- import { t as QueryClient } from "./queryClient-CZeNAt68.cjs";
1
+ import { t as QueryClient } from "./queryClient-Bn2Ql_Lu.cjs";
2
2
  //#region src/useQueryClient.d.ts
3
3
  /**
4
4
  * Retrieves the `QueryClient` installed by `VueQueryPlugin`, via Vue's `inject`. Must be called inside
@@ -1,4 +1,4 @@
1
- import { t as QueryClient } from "./queryClient-Cv73nzNT.js";
1
+ import { t as QueryClient } from "./queryClient-B6mLtXOj.js";
2
2
  //#region src/useQueryClient.d.ts
3
3
  /**
4
4
  * Retrieves the `QueryClient` installed by `VueQueryPlugin`, via Vue's `inject`. Must be called inside
@@ -1,5 +1,5 @@
1
1
  import { u as QueryClientConfig } from "./types-JpJB72CS.cjs";
2
- import { t as QueryClient } from "./queryClient-CZeNAt68.cjs";
2
+ import { t as QueryClient } from "./queryClient-Bn2Ql_Lu.cjs";
3
3
  //#region src/vueQueryPlugin.d.ts
4
4
  type ClientPersister = (client: QueryClient) => [() => void, Promise<void>];
5
5
  interface CommonOptions {
@@ -1,5 +1,5 @@
1
1
  import { u as QueryClientConfig } from "./types-JpJB72CS.js";
2
- import { t as QueryClient } from "./queryClient-Cv73nzNT.js";
2
+ import { t as QueryClient } from "./queryClient-B6mLtXOj.js";
3
3
  //#region src/vueQueryPlugin.d.ts
4
4
  type ClientPersister = (client: QueryClient) => [() => void, Promise<void>];
5
5
  interface CommonOptions {
@@ -1,4 +1,4 @@
1
- import { t as QueryClient } from "../queryClient-CZeNAt68.cjs";
1
+ import { t as QueryClient } from "../queryClient-Bn2Ql_Lu.cjs";
2
2
  //#region src/devtools/devtools.d.ts
3
3
  declare function setupDevtools(app: any, queryClient: QueryClient): void;
4
4
  //#endregion
@@ -1,4 +1,4 @@
1
- import { t as QueryClient } from "../queryClient-Cv73nzNT.js";
1
+ import { t as QueryClient } from "../queryClient-B6mLtXOj.js";
2
2
  //#region src/devtools/devtools.d.ts
3
3
  declare function setupDevtools(app: any, queryClient: QueryClient): void;
4
4
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.cts","names":[],"sources":["../../../src/devtools/utils.ts"],"mappings":";;KAEK,UAAU,GAAG,OAAO,GAAG;aAEvB;EACH;EACA;EACA;EACA;EACA;;iBAGc,cAAc,OAAO,QAAQ;iBAiB7B,mBAAmB,OAAO;iBAmB1B,iBAAiB,OAAO;iBAUxB,iBAAiB,OAAO;cAgC3B,SAAS,eAAe"}
1
+ {"version":3,"file":"utils.d.cts","names":["QueryState"],"sources":["../../../src/devtools/utils.ts"],"mappings":";;KAEK,UAAU,GAAG,OAAO,GAAG;aAEvBA;EACH;EACA;EACA;EACA;EACA;;iBAGc,cAAc,OAAO,QAAQA;iBAiB7B,mBAAmB,OAAO;iBAmB1B,iBAAiB,OAAO;iBAUxB,iBAAiB,OAAO;cAgC3B,SAAS,eAAe"}
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","names":[],"sources":["../../../src/devtools/utils.ts"],"mappings":";;KAEK,UAAU,GAAG,OAAO,GAAG;aAEvB;EACH;EACA;EACA;EACA;EACA;;iBAGc,cAAc,OAAO,QAAQ;iBAiB7B,mBAAmB,OAAO;iBAmB1B,iBAAiB,OAAO;iBAUxB,iBAAiB,OAAO;cAgC3B,SAAS,eAAe"}
1
+ {"version":3,"file":"utils.d.ts","names":["QueryState"],"sources":["../../../src/devtools/utils.ts"],"mappings":";;KAEK,UAAU,GAAG,OAAO,GAAG;aAEvBA;EACH;EACA;EACA;EACA;EACA;;iBAGc,cAAc,OAAO,QAAQA;iBAiB7B,mBAAmB,OAAO;iBAmB1B,iBAAiB,OAAO;iBAUxB,iBAAiB,OAAO;cAgC3B,SAAS,eAAe"}
@@ -1,10 +1,10 @@
1
1
  import { c as MutationOptions } from "./types-JpJB72CS.cjs";
2
- import { a as UndefinedInitialQueryOptionsWithDataTag, i as UndefinedInitialQueryOptions, n as DefinedInitialQueryOptionsWithDataTag, o as UseQueryOptions, r as QueryOptions, s as queryOptions, t as DefinedInitialQueryOptions } from "./queryOptions-rkZ3sk6g.cjs";
3
- import { t as QueryClient } from "./queryClient-CZeNAt68.cjs";
2
+ import { a as UndefinedInitialQueryOptionsWithDataTag, i as UndefinedInitialQueryOptions, n as DefinedInitialQueryOptionsWithDataTag, o as UseQueryOptions, r as QueryOptions, s as queryOptions, t as DefinedInitialQueryOptions } from "./queryOptions-CwqQgQmQ.cjs";
3
+ import { t as QueryClient } from "./queryClient-Bn2Ql_Lu.cjs";
4
4
  import { useQueryClient } from "./useQueryClient.cjs";
5
5
  import { VueQueryPlugin, VueQueryPluginOptions } from "./vueQueryPlugin.cjs";
6
6
  import { QueryCache } from "./queryCache.cjs";
7
- import { a as UseInfiniteQueryReturnType, i as UseInfiniteQueryOptions, n as UndefinedInitialDataInfiniteOptions, o as useInfiniteQuery, r as infiniteQueryOptions, t as DefinedInitialDataInfiniteOptions } from "./infiniteQueryOptions-qN6sOJM-.cjs";
7
+ import { a as UseInfiniteQueryReturnType, i as UseInfiniteQueryOptions, n as UndefinedInitialDataInfiniteOptions, o as useInfiniteQuery, r as infiniteQueryOptions, t as DefinedInitialDataInfiniteOptions } from "./infiniteQueryOptions-CnTRbIP5.cjs";
8
8
  import { MutationCache } from "./mutationCache.cjs";
9
9
  import { mutationOptions } from "./mutationOptions.cjs";
10
10
  import { UseQueryDefinedReturnType, UseQueryReturnType, useQuery } from "./useQuery.cjs";
@@ -1,10 +1,10 @@
1
1
  import { c as MutationOptions } from "./types-JpJB72CS.js";
2
- import { a as UndefinedInitialQueryOptionsWithDataTag, i as UndefinedInitialQueryOptions, n as DefinedInitialQueryOptionsWithDataTag, o as UseQueryOptions, r as QueryOptions, s as queryOptions, t as DefinedInitialQueryOptions } from "./queryOptions-DPDwdVBu.js";
3
- import { t as QueryClient } from "./queryClient-Cv73nzNT.js";
2
+ import { a as UndefinedInitialQueryOptionsWithDataTag, i as UndefinedInitialQueryOptions, n as DefinedInitialQueryOptionsWithDataTag, o as UseQueryOptions, r as QueryOptions, s as queryOptions, t as DefinedInitialQueryOptions } from "./queryOptions-CsM5TXD2.js";
3
+ import { t as QueryClient } from "./queryClient-B6mLtXOj.js";
4
4
  import { useQueryClient } from "./useQueryClient.js";
5
5
  import { VueQueryPlugin, VueQueryPluginOptions } from "./vueQueryPlugin.js";
6
6
  import { QueryCache } from "./queryCache.js";
7
- import { a as UseInfiniteQueryReturnType, i as UseInfiniteQueryOptions, n as UndefinedInitialDataInfiniteOptions, o as useInfiniteQuery, r as infiniteQueryOptions, t as DefinedInitialDataInfiniteOptions } from "./infiniteQueryOptions-CEDiLwh5.js";
7
+ import { a as UseInfiniteQueryReturnType, i as UseInfiniteQueryOptions, n as UndefinedInitialDataInfiniteOptions, o as useInfiniteQuery, r as infiniteQueryOptions, t as DefinedInitialDataInfiniteOptions } from "./infiniteQueryOptions-NucMX_M_.js";
8
8
  import { MutationCache } from "./mutationCache.js";
9
9
  import { mutationOptions } from "./mutationOptions.js";
10
10
  import { UseQueryDefinedReturnType, UseQueryReturnType, useQuery } from "./useQuery.js";
@@ -1,10 +1,18 @@
1
1
  import { a as MaybeRef, d as ShallowOption, o as MaybeRefDeep, s as MaybeRefOrGetter, t as DeepUnwrapRef } from "./types-JpJB72CS.cjs";
2
- import { o as UseQueryOptions } from "./queryOptions-rkZ3sk6g.cjs";
3
- import { t as QueryClient$1 } from "./queryClient-CZeNAt68.cjs";
2
+ import { o as UseQueryOptions } from "./queryOptions-CwqQgQmQ.cjs";
3
+ import { t as QueryClient$1 } from "./queryClient-Bn2Ql_Lu.cjs";
4
4
  import { DefaultError, InfiniteData, InfiniteQueryObserverOptions, InfiniteQueryObserverResult, NonUndefinedGuard, QueryKey, QueryKeyWithDataTag, QueryObserver, QueryObserverResult } from "@tanstack/query-core";
5
5
  import { Ref } from "vue-demi";
6
6
  //#region src/useBaseQuery.d.ts
7
7
  type UseBaseQueryReturnType<TData, TError, TResult = QueryObserverResult<TData, TError>> = { [K in keyof TResult]: K extends 'fetchNextPage' | 'fetchPreviousPage' | 'refetch' ? TResult[K] : Ref<Readonly<TResult>[K]>; } & {
8
+ /**
9
+ * Returns a promise for use with Vue's `Suspense` or `onServerPrefetch`. It fetches the query if it has no
10
+ * data or its data is stale and resolves with the result once that fetch resolves (usually when the query
11
+ * function finishes, but earlier after the first chunk of a streamed query or when data is set during the
12
+ * fetch), or resolves immediately if the data is fresh. While the query is disabled, it waits until the query
13
+ * is enabled. If the fetch fails, it resolves with the error result, unless `throwOnError` is (or returns)
14
+ * `true`, in which case it rejects.
15
+ */
8
16
  suspense: () => Promise<TResult>;
9
17
  };
10
18
  type UseQueryOptionsGeneric<TQueryFnData, TError, TData, TQueryData, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown> = UseQueryOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey> | UseInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>;
@@ -25,7 +33,8 @@ type UseInfiniteQueryReturnType<TData, TError> = UseBaseQueryReturnType<TData, T
25
33
  * The options for `useInfiniteQuery` are identical to `useQuery`, with the addition of
26
34
  * `initialPageParam`, `getNextPageParam`, `getPreviousPageParam`, and `maxPages`.
27
35
  *
28
- * This overload is selected when `initialData` is set, so the resulting `data` is never `undefined`.
36
+ * This overload is selected when `initialData` is set, so the resulting `data` is never `undefined` (unless
37
+ * a `select` changes `TData` to include `undefined`).
29
38
  *
30
39
  * `enabled` tracks reactive dependencies automatically as a `ref`, a plain value, or a reactive getter
31
40
  * (`() => ...`). `queryKey` reacts through a `ref` for the array itself, or `ref`s and reactive getters as
@@ -282,7 +291,7 @@ type UndefinedInitialDataInfiniteOptions<TQueryFnData, TError = DefaultError, TD
282
291
  };
283
292
  /**
284
293
  * The options accepted by the `infiniteQueryOptions` overload selected when `initialData` is set — `data` is
285
- * never `undefined`.
294
+ * never `undefined` (unless a `select` changes `TData` to include `undefined`).
286
295
  *
287
296
  * @template TQueryFnData - The type of a single page, as your `queryFn` resolves it.
288
297
  * @template TError - The type of errors your `queryFn` may throw.
@@ -333,7 +342,8 @@ declare function infiniteQueryOptions<TQueryFnData, TError = DefaultError, TData
333
342
  * These options can be shared across hooks and imperative APIs such as `queryClient.infiniteQuery`.
334
343
  * `options.queryKey` is required and is the query key to generate options for.
335
344
  *
336
- * This overload is selected when `initialData` is set, so the resulting `data` is never `undefined`.
345
+ * This overload is selected when `initialData` is set, so the resulting `data` is never `undefined` (unless
346
+ * a `select` changes `TData` to include `undefined`).
337
347
  *
338
348
  * @see {@link useInfiniteQuery} to run an infinite query with these options.
339
349
  * @param options - The {@link DefinedInitialDataInfiniteOptions} to use — everything you can pass to
@@ -362,4 +372,4 @@ declare function infiniteQueryOptions<TQueryFnData, TError = DefaultError, TData
362
372
  declare function infiniteQueryOptions<TQueryFnData, TError = DefaultError, TData = InfiniteData<TQueryFnData>, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown>(options: DefinedInitialDataInfiniteOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>): DefinedInitialDataInfiniteOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam> & QueryKeyWithDataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>;
363
373
  //#endregion
364
374
  export { UseInfiniteQueryReturnType as a, useBaseQuery as c, UseInfiniteQueryOptions as i, UndefinedInitialDataInfiniteOptions as n, useInfiniteQuery as o, infiniteQueryOptions as r, UseBaseQueryReturnType as s, DefinedInitialDataInfiniteOptions as t };
365
- //# sourceMappingURL=infiniteQueryOptions-qN6sOJM-.d.cts.map
375
+ //# sourceMappingURL=infiniteQueryOptions-CnTRbIP5.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"infiniteQueryOptions-CnTRbIP5.d.cts","names":["QueryClient","QueryClient"],"sources":["../../src/useBaseQuery.ts","../../src/useInfiniteQuery.ts","../../src/infiniteQueryOptions.ts"],"mappings":";;;;;;KA0BY,uBACV,OACA,QACA,UAAU,oBAAoB,OAAO,cAEpC,WAAW,UAAU,8DAElB,QAAQ,KACR,IAAI,SAAS,SAAS;;;;;;;;;EAU1B,gBAAgB,QAAQ;;KAGrB,uBACH,cACA,QACA,OACA,YACA,kBAAkB,WAAW,UAC7B,wBAEE,gBAAgB,cAAc,QAAQ,OAAO,YAAY,aACzD,wBAAwB,cAAc,QAAQ,OAAO,WAAW;;;;;;;;;iBAUpD,aACd,cACA,QACA,OACA,YACA,kBAAkB,UAClB,YAEA,iBAAiB,eACjB,SAAS,iBACP,uBACE,cACA,QACA,OACA,YACA,WACA,cAGJ,cAAcA,gBACb,uBAAuB,OAAO;;;KC5DrB,wBACV,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,UAC7B,wBACE,YAGE,kBAAkB,6BAChB,cACA,QACA,OACA,WACA,cAED,6BACC,iBACE,6BACE,cACA,QACA,OACA,cAAc,YACd,YACA,aAEJ,aACE,6BACE,cACA,QACA,OACA,cAAc,YACd,YACA,gBAEN;KAGM,2BAA2B,OAAO,UAAU,uBACtD,OACA,QACA,4BAA4B,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAoDrB,iBACd,cACA,SAAS,cACT,QAAQ,aAAa,eACrB,kBAAkB,WAAW,UAC7B,sBAEA,SAAS,iBACP,kCACE,cACA,QACA,OACA,WACA,cAGJ,cAAcC,gBACb,2BAA2B,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAqHrB,iBACd,cACA,SAAS,cACT,QAAQ,aAAa,eACrB,kBAAkB,WAAW,UAC7B,sBAEA,SAAS,iBACP,oCACE,cACA,QACA,OACA,WACA,cAGJ,cAAcA,gBACb,2BAA2B,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA+ErB,iBACd,cACA,SAAS,cACT,QAAQ,aAAa,eACrB,kBAAkB,WAAW,UAC7B,sBAEA,SAAS,iBACP,wBAAwB,cAAc,QAAQ,OAAO,WAAW,cAElE,cAAcA,gBACb,2BAA2B,OAAO;;;;;;;;;;;;;;KCpVzB,oCACV,cACA,SAAS,cACT,QAAQ,aAAa,eACrB,kBAAkB,WAAW,UAC7B,wBACE,wBACF,cACA,QACA,OACA,WACA;EAEA;;;;;;;;;;;;;KAcU,kCACV,cACA,SAAS,cACT,QAAQ,aAAa,eACrB,kBAAkB,WAAW,UAC7B,wBACE,wBACF,cACA,QACA,OACA,WACA;;;;;;;;EASA,aACI,kBAAkB,aAAa,cAAc,sBACtC,kBAAkB,aAAa,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA6B1C,qBACd,cACA,SAAS,cACT,QAAQ,aAAa,eACrB,kBAAkB,WAAW,UAC7B,sBAEA,SAAS,oCACP,cACA,QACA,OACA,WACA,cAED,oCACD,cACA,QACA,OACA,WACA,cAEA,oBAAoB,WAAW,aAAa,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAkC7C,qBACd,cACA,SAAS,cACT,QAAQ,aAAa,eACrB,kBAAkB,WAAW,UAC7B,sBAEA,SAAS,kCACP,cACA,QACA,OACA,WACA,cAED,kCACD,cACA,QACA,OACA,WACA,cAEA,oBAAoB,WAAW,aAAa,eAAe"}
@@ -1,10 +1,18 @@
1
1
  import { a as MaybeRef, d as ShallowOption, o as MaybeRefDeep, s as MaybeRefOrGetter, t as DeepUnwrapRef } from "./types-JpJB72CS.js";
2
- import { o as UseQueryOptions } from "./queryOptions-DPDwdVBu.js";
3
- import { t as QueryClient$1 } from "./queryClient-Cv73nzNT.js";
2
+ import { o as UseQueryOptions } from "./queryOptions-CsM5TXD2.js";
3
+ import { t as QueryClient$1 } from "./queryClient-B6mLtXOj.js";
4
4
  import { DefaultError, InfiniteData, InfiniteQueryObserverOptions, InfiniteQueryObserverResult, NonUndefinedGuard, QueryKey, QueryKeyWithDataTag, QueryObserver, QueryObserverResult } from "@tanstack/query-core";
5
5
  import { Ref } from "vue-demi";
6
6
  //#region src/useBaseQuery.d.ts
7
7
  type UseBaseQueryReturnType<TData, TError, TResult = QueryObserverResult<TData, TError>> = { [K in keyof TResult]: K extends 'fetchNextPage' | 'fetchPreviousPage' | 'refetch' ? TResult[K] : Ref<Readonly<TResult>[K]>; } & {
8
+ /**
9
+ * Returns a promise for use with Vue's `Suspense` or `onServerPrefetch`. It fetches the query if it has no
10
+ * data or its data is stale and resolves with the result once that fetch resolves (usually when the query
11
+ * function finishes, but earlier after the first chunk of a streamed query or when data is set during the
12
+ * fetch), or resolves immediately if the data is fresh. While the query is disabled, it waits until the query
13
+ * is enabled. If the fetch fails, it resolves with the error result, unless `throwOnError` is (or returns)
14
+ * `true`, in which case it rejects.
15
+ */
8
16
  suspense: () => Promise<TResult>;
9
17
  };
10
18
  type UseQueryOptionsGeneric<TQueryFnData, TError, TData, TQueryData, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown> = UseQueryOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey> | UseInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>;
@@ -25,7 +33,8 @@ type UseInfiniteQueryReturnType<TData, TError> = UseBaseQueryReturnType<TData, T
25
33
  * The options for `useInfiniteQuery` are identical to `useQuery`, with the addition of
26
34
  * `initialPageParam`, `getNextPageParam`, `getPreviousPageParam`, and `maxPages`.
27
35
  *
28
- * This overload is selected when `initialData` is set, so the resulting `data` is never `undefined`.
36
+ * This overload is selected when `initialData` is set, so the resulting `data` is never `undefined` (unless
37
+ * a `select` changes `TData` to include `undefined`).
29
38
  *
30
39
  * `enabled` tracks reactive dependencies automatically as a `ref`, a plain value, or a reactive getter
31
40
  * (`() => ...`). `queryKey` reacts through a `ref` for the array itself, or `ref`s and reactive getters as
@@ -282,7 +291,7 @@ type UndefinedInitialDataInfiniteOptions<TQueryFnData, TError = DefaultError, TD
282
291
  };
283
292
  /**
284
293
  * The options accepted by the `infiniteQueryOptions` overload selected when `initialData` is set — `data` is
285
- * never `undefined`.
294
+ * never `undefined` (unless a `select` changes `TData` to include `undefined`).
286
295
  *
287
296
  * @template TQueryFnData - The type of a single page, as your `queryFn` resolves it.
288
297
  * @template TError - The type of errors your `queryFn` may throw.
@@ -333,7 +342,8 @@ declare function infiniteQueryOptions<TQueryFnData, TError = DefaultError, TData
333
342
  * These options can be shared across hooks and imperative APIs such as `queryClient.infiniteQuery`.
334
343
  * `options.queryKey` is required and is the query key to generate options for.
335
344
  *
336
- * This overload is selected when `initialData` is set, so the resulting `data` is never `undefined`.
345
+ * This overload is selected when `initialData` is set, so the resulting `data` is never `undefined` (unless
346
+ * a `select` changes `TData` to include `undefined`).
337
347
  *
338
348
  * @see {@link useInfiniteQuery} to run an infinite query with these options.
339
349
  * @param options - The {@link DefinedInitialDataInfiniteOptions} to use — everything you can pass to
@@ -362,4 +372,4 @@ declare function infiniteQueryOptions<TQueryFnData, TError = DefaultError, TData
362
372
  declare function infiniteQueryOptions<TQueryFnData, TError = DefaultError, TData = InfiniteData<TQueryFnData>, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown>(options: DefinedInitialDataInfiniteOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>): DefinedInitialDataInfiniteOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam> & QueryKeyWithDataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>;
363
373
  //#endregion
364
374
  export { UseInfiniteQueryReturnType as a, useBaseQuery as c, UseInfiniteQueryOptions as i, UndefinedInitialDataInfiniteOptions as n, useInfiniteQuery as o, infiniteQueryOptions as r, UseBaseQueryReturnType as s, DefinedInitialDataInfiniteOptions as t };
365
- //# sourceMappingURL=infiniteQueryOptions-CEDiLwh5.d.ts.map
375
+ //# sourceMappingURL=infiniteQueryOptions-NucMX_M_.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"infiniteQueryOptions-NucMX_M_.d.ts","names":["QueryClient","QueryClient"],"sources":["../../src/useBaseQuery.ts","../../src/useInfiniteQuery.ts","../../src/infiniteQueryOptions.ts"],"mappings":";;;;;;KA0BY,uBACV,OACA,QACA,UAAU,oBAAoB,OAAO,cAEpC,WAAW,UAAU,8DAElB,QAAQ,KACR,IAAI,SAAS,SAAS;;;;;;;;;EAU1B,gBAAgB,QAAQ;;KAGrB,uBACH,cACA,QACA,OACA,YACA,kBAAkB,WAAW,UAC7B,wBAEE,gBAAgB,cAAc,QAAQ,OAAO,YAAY,aACzD,wBAAwB,cAAc,QAAQ,OAAO,WAAW;;;;;;;;;iBAUpD,aACd,cACA,QACA,OACA,YACA,kBAAkB,UAClB,YAEA,iBAAiB,eACjB,SAAS,iBACP,uBACE,cACA,QACA,OACA,YACA,WACA,cAGJ,cAAcA,gBACb,uBAAuB,OAAO;;;KC5DrB,wBACV,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,UAC7B,wBACE,YAGE,kBAAkB,6BAChB,cACA,QACA,OACA,WACA,cAED,6BACC,iBACE,6BACE,cACA,QACA,OACA,cAAc,YACd,YACA,aAEJ,aACE,6BACE,cACA,QACA,OACA,cAAc,YACd,YACA,gBAEN;KAGM,2BAA2B,OAAO,UAAU,uBACtD,OACA,QACA,4BAA4B,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAoDrB,iBACd,cACA,SAAS,cACT,QAAQ,aAAa,eACrB,kBAAkB,WAAW,UAC7B,sBAEA,SAAS,iBACP,kCACE,cACA,QACA,OACA,WACA,cAGJ,cAAcC,gBACb,2BAA2B,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAqHrB,iBACd,cACA,SAAS,cACT,QAAQ,aAAa,eACrB,kBAAkB,WAAW,UAC7B,sBAEA,SAAS,iBACP,oCACE,cACA,QACA,OACA,WACA,cAGJ,cAAcA,gBACb,2BAA2B,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA+ErB,iBACd,cACA,SAAS,cACT,QAAQ,aAAa,eACrB,kBAAkB,WAAW,UAC7B,sBAEA,SAAS,iBACP,wBAAwB,cAAc,QAAQ,OAAO,WAAW,cAElE,cAAcA,gBACb,2BAA2B,OAAO;;;;;;;;;;;;;;KCpVzB,oCACV,cACA,SAAS,cACT,QAAQ,aAAa,eACrB,kBAAkB,WAAW,UAC7B,wBACE,wBACF,cACA,QACA,OACA,WACA;EAEA;;;;;;;;;;;;;KAcU,kCACV,cACA,SAAS,cACT,QAAQ,aAAa,eACrB,kBAAkB,WAAW,UAC7B,wBACE,wBACF,cACA,QACA,OACA,WACA;;;;;;;;EASA,aACI,kBAAkB,aAAa,cAAc,sBACtC,kBAAkB,aAAa,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA6B1C,qBACd,cACA,SAAS,cACT,QAAQ,aAAa,eACrB,kBAAkB,WAAW,UAC7B,sBAEA,SAAS,oCACP,cACA,QACA,OACA,WACA,cAED,oCACD,cACA,QACA,OACA,WACA,cAEA,oBAAoB,WAAW,aAAa,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAkC7C,qBACd,cACA,SAAS,cACT,QAAQ,aAAa,eACrB,kBAAkB,WAAW,UAC7B,sBAEA,SAAS,kCACP,cACA,QACA,OACA,WACA,cAED,kCACD,cACA,QACA,OACA,WACA,cAEA,oBAAoB,WAAW,aAAa,eAAe"}
@@ -1 +1 @@
1
- {"version":3,"file":"infiniteQueryOptions.cjs","names":[],"sources":["../../src/infiniteQueryOptions.ts"],"sourcesContent":["import type {\n DefaultError,\n InfiniteData,\n NonUndefinedGuard,\n QueryKey,\n QueryKeyWithDataTag,\n} from '@tanstack/query-core'\nimport type { UseInfiniteQueryOptions } from './useInfiniteQuery'\n\n/**\n * The options accepted by the `infiniteQueryOptions` overload selected when no `initialData` is set — `data`\n * may be `undefined` while the query is `pending`.\n *\n * @template TQueryFnData - The type of a single page, as your `queryFn` resolves it.\n * @template TError - The type of errors your `queryFn` may throw.\n * @template TData - The type `data` ends up as after `select` runs — defaults to `InfiniteData<TQueryFnData>`,\n * the shape of all fetched pages plus their page params.\n * @template TQueryKey - The type of your `queryKey`.\n * @template TPageParam - The type of the parameter passed to `queryFn` to fetch a given page.\n */\nexport type UndefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n> = UseInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n> & {\n initialData?: undefined\n}\n\n/**\n * The options accepted by the `infiniteQueryOptions` overload selected when `initialData` is set — `data` is\n * never `undefined`.\n *\n * @template TQueryFnData - The type of a single page, as your `queryFn` resolves it.\n * @template TError - The type of errors your `queryFn` may throw.\n * @template TData - The type `data` ends up as after `select` runs — defaults to `InfiniteData<TQueryFnData>`,\n * the shape of all fetched pages plus their page params.\n * @template TQueryKey - The type of your `queryKey`.\n * @template TPageParam - The type of the parameter passed to `queryFn` to fetch a given page.\n */\nexport type DefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n> = UseInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n> & {\n /**\n * If set, this value will be used as the initial data for the query cache (as long as the query hasn't been\n * created or cached yet). If set to a function, the function will be called **once** during the shared/root\n * query initialization, and be expected to synchronously return the initial data. Initial data is\n * considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the\n * cache.\n */\n initialData:\n | NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>\n | (() => NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>)\n}\n\n/**\n * You can generally pass everything to `infiniteQueryOptions` that you can also pass to `useInfiniteQuery`.\n * These options can be shared across hooks and imperative APIs such as `queryClient.infiniteQuery`.\n * `options.queryKey` is required and is the query key to generate options for.\n *\n * @see {@link useInfiniteQuery} to run an infinite query with these options.\n * @param options - The {@link UndefinedInitialDataInfiniteOptions} to use — everything you can pass to\n * `useInfiniteQuery`.\n * @returns The same options object, typed so that `queryKey` carries the inferred data type.\n *\n * @example\n * ```vue\n * <script setup lang=\"ts\">\n * import { infiniteQueryOptions, useInfiniteQuery } from '@tanstack/vue-query'\n *\n * const projectsOptions = infiniteQueryOptions({\n * queryKey: ['projects'],\n * queryFn: ({ pageParam }) => fetchProjects(pageParam),\n * initialPageParam: 0,\n * getNextPageParam: (lastPage) => lastPage.nextId,\n * })\n *\n * const { data, isError, error, fetchNextPage } = useInfiniteQuery(projectsOptions)\n * </script>\n * ```\n */\nexport function infiniteQueryOptions<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: UndefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n): UndefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n> &\n QueryKeyWithDataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>\n\n/**\n * You can generally pass everything to `infiniteQueryOptions` that you can also pass to `useInfiniteQuery`.\n * These options can be shared across hooks and imperative APIs such as `queryClient.infiniteQuery`.\n * `options.queryKey` is required and is the query key to generate options for.\n *\n * This overload is selected when `initialData` is set, so the resulting `data` is never `undefined`.\n *\n * @see {@link useInfiniteQuery} to run an infinite query with these options.\n * @param options - The {@link DefinedInitialDataInfiniteOptions} to use — everything you can pass to\n * `useInfiniteQuery`, with `initialData` set.\n * @returns The same options object, typed so that `queryKey` carries the inferred data type.\n *\n * @example\n * ```vue\n * <script setup lang=\"ts\">\n * import { infiniteQueryOptions, useInfiniteQuery } from '@tanstack/vue-query'\n *\n * const projectsOptions = infiniteQueryOptions({\n * queryKey: ['projects'],\n * queryFn: ({ pageParam }) => fetchProjects(pageParam),\n * initialPageParam: 0,\n * getNextPageParam: (lastPage) => lastPage.nextId,\n * initialData: { pages: [], pageParams: [] },\n * })\n *\n * // `data` is never `undefined`, thanks to `initialData` — even if a refetch fails, so the\n * // list stays visible alongside the error.\n * const { data, isError, error } = useInfiniteQuery(projectsOptions)\n * </script>\n * ```\n */\nexport function infiniteQueryOptions<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: DefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n): DefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n> &\n QueryKeyWithDataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>\n\nexport function infiniteQueryOptions(options: unknown) {\n return options\n}\n"],"mappings":";;AA+KA,SAAgB,qBAAqB,SAAkB;CACrD,OAAO;AACT"}
1
+ {"version":3,"file":"infiniteQueryOptions.cjs","names":[],"sources":["../../src/infiniteQueryOptions.ts"],"sourcesContent":["import type {\n DefaultError,\n InfiniteData,\n NonUndefinedGuard,\n QueryKey,\n QueryKeyWithDataTag,\n} from '@tanstack/query-core'\nimport type { UseInfiniteQueryOptions } from './useInfiniteQuery'\n\n/**\n * The options accepted by the `infiniteQueryOptions` overload selected when no `initialData` is set — `data`\n * may be `undefined` while the query is `pending`.\n *\n * @template TQueryFnData - The type of a single page, as your `queryFn` resolves it.\n * @template TError - The type of errors your `queryFn` may throw.\n * @template TData - The type `data` ends up as after `select` runs — defaults to `InfiniteData<TQueryFnData>`,\n * the shape of all fetched pages plus their page params.\n * @template TQueryKey - The type of your `queryKey`.\n * @template TPageParam - The type of the parameter passed to `queryFn` to fetch a given page.\n */\nexport type UndefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n> = UseInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n> & {\n initialData?: undefined\n}\n\n/**\n * The options accepted by the `infiniteQueryOptions` overload selected when `initialData` is set — `data` is\n * never `undefined` (unless a `select` changes `TData` to include `undefined`).\n *\n * @template TQueryFnData - The type of a single page, as your `queryFn` resolves it.\n * @template TError - The type of errors your `queryFn` may throw.\n * @template TData - The type `data` ends up as after `select` runs — defaults to `InfiniteData<TQueryFnData>`,\n * the shape of all fetched pages plus their page params.\n * @template TQueryKey - The type of your `queryKey`.\n * @template TPageParam - The type of the parameter passed to `queryFn` to fetch a given page.\n */\nexport type DefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n> = UseInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n> & {\n /**\n * If set, this value will be used as the initial data for the query cache (as long as the query hasn't been\n * created or cached yet). If set to a function, the function will be called **once** during the shared/root\n * query initialization, and be expected to synchronously return the initial data. Initial data is\n * considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the\n * cache.\n */\n initialData:\n | NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>\n | (() => NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>)\n}\n\n/**\n * You can generally pass everything to `infiniteQueryOptions` that you can also pass to `useInfiniteQuery`.\n * These options can be shared across hooks and imperative APIs such as `queryClient.infiniteQuery`.\n * `options.queryKey` is required and is the query key to generate options for.\n *\n * @see {@link useInfiniteQuery} to run an infinite query with these options.\n * @param options - The {@link UndefinedInitialDataInfiniteOptions} to use — everything you can pass to\n * `useInfiniteQuery`.\n * @returns The same options object, typed so that `queryKey` carries the inferred data type.\n *\n * @example\n * ```vue\n * <script setup lang=\"ts\">\n * import { infiniteQueryOptions, useInfiniteQuery } from '@tanstack/vue-query'\n *\n * const projectsOptions = infiniteQueryOptions({\n * queryKey: ['projects'],\n * queryFn: ({ pageParam }) => fetchProjects(pageParam),\n * initialPageParam: 0,\n * getNextPageParam: (lastPage) => lastPage.nextId,\n * })\n *\n * const { data, isError, error, fetchNextPage } = useInfiniteQuery(projectsOptions)\n * </script>\n * ```\n */\nexport function infiniteQueryOptions<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: UndefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n): UndefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n> &\n QueryKeyWithDataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>\n\n/**\n * You can generally pass everything to `infiniteQueryOptions` that you can also pass to `useInfiniteQuery`.\n * These options can be shared across hooks and imperative APIs such as `queryClient.infiniteQuery`.\n * `options.queryKey` is required and is the query key to generate options for.\n *\n * This overload is selected when `initialData` is set, so the resulting `data` is never `undefined` (unless\n * a `select` changes `TData` to include `undefined`).\n *\n * @see {@link useInfiniteQuery} to run an infinite query with these options.\n * @param options - The {@link DefinedInitialDataInfiniteOptions} to use — everything you can pass to\n * `useInfiniteQuery`, with `initialData` set.\n * @returns The same options object, typed so that `queryKey` carries the inferred data type.\n *\n * @example\n * ```vue\n * <script setup lang=\"ts\">\n * import { infiniteQueryOptions, useInfiniteQuery } from '@tanstack/vue-query'\n *\n * const projectsOptions = infiniteQueryOptions({\n * queryKey: ['projects'],\n * queryFn: ({ pageParam }) => fetchProjects(pageParam),\n * initialPageParam: 0,\n * getNextPageParam: (lastPage) => lastPage.nextId,\n * initialData: { pages: [], pageParams: [] },\n * })\n *\n * // `data` is never `undefined`, thanks to `initialData` — even if a refetch fails, so the\n * // list stays visible alongside the error.\n * const { data, isError, error } = useInfiniteQuery(projectsOptions)\n * </script>\n * ```\n */\nexport function infiniteQueryOptions<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: DefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n): DefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n> &\n QueryKeyWithDataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>\n\nexport function infiniteQueryOptions(options: unknown) {\n return options\n}\n"],"mappings":";;AAgLA,SAAgB,qBAAqB,SAAkB;CACrD,OAAO;AACT"}
@@ -1,2 +1,2 @@
1
- import { n as UndefinedInitialDataInfiniteOptions, r as infiniteQueryOptions, t as DefinedInitialDataInfiniteOptions } from "./infiniteQueryOptions-qN6sOJM-.cjs";
1
+ import { n as UndefinedInitialDataInfiniteOptions, r as infiniteQueryOptions, t as DefinedInitialDataInfiniteOptions } from "./infiniteQueryOptions-CnTRbIP5.cjs";
2
2
  export { DefinedInitialDataInfiniteOptions, UndefinedInitialDataInfiniteOptions, infiniteQueryOptions };
@@ -1,2 +1,2 @@
1
- import { n as UndefinedInitialDataInfiniteOptions, r as infiniteQueryOptions, t as DefinedInitialDataInfiniteOptions } from "./infiniteQueryOptions-CEDiLwh5.js";
1
+ import { n as UndefinedInitialDataInfiniteOptions, r as infiniteQueryOptions, t as DefinedInitialDataInfiniteOptions } from "./infiniteQueryOptions-NucMX_M_.js";
2
2
  export { DefinedInitialDataInfiniteOptions, UndefinedInitialDataInfiniteOptions, infiniteQueryOptions };
@@ -1 +1 @@
1
- {"version":3,"file":"infiniteQueryOptions.js","names":[],"sources":["../../src/infiniteQueryOptions.ts"],"sourcesContent":["import type {\n DefaultError,\n InfiniteData,\n NonUndefinedGuard,\n QueryKey,\n QueryKeyWithDataTag,\n} from '@tanstack/query-core'\nimport type { UseInfiniteQueryOptions } from './useInfiniteQuery'\n\n/**\n * The options accepted by the `infiniteQueryOptions` overload selected when no `initialData` is set — `data`\n * may be `undefined` while the query is `pending`.\n *\n * @template TQueryFnData - The type of a single page, as your `queryFn` resolves it.\n * @template TError - The type of errors your `queryFn` may throw.\n * @template TData - The type `data` ends up as after `select` runs — defaults to `InfiniteData<TQueryFnData>`,\n * the shape of all fetched pages plus their page params.\n * @template TQueryKey - The type of your `queryKey`.\n * @template TPageParam - The type of the parameter passed to `queryFn` to fetch a given page.\n */\nexport type UndefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n> = UseInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n> & {\n initialData?: undefined\n}\n\n/**\n * The options accepted by the `infiniteQueryOptions` overload selected when `initialData` is set — `data` is\n * never `undefined`.\n *\n * @template TQueryFnData - The type of a single page, as your `queryFn` resolves it.\n * @template TError - The type of errors your `queryFn` may throw.\n * @template TData - The type `data` ends up as after `select` runs — defaults to `InfiniteData<TQueryFnData>`,\n * the shape of all fetched pages plus their page params.\n * @template TQueryKey - The type of your `queryKey`.\n * @template TPageParam - The type of the parameter passed to `queryFn` to fetch a given page.\n */\nexport type DefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n> = UseInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n> & {\n /**\n * If set, this value will be used as the initial data for the query cache (as long as the query hasn't been\n * created or cached yet). If set to a function, the function will be called **once** during the shared/root\n * query initialization, and be expected to synchronously return the initial data. Initial data is\n * considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the\n * cache.\n */\n initialData:\n | NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>\n | (() => NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>)\n}\n\n/**\n * You can generally pass everything to `infiniteQueryOptions` that you can also pass to `useInfiniteQuery`.\n * These options can be shared across hooks and imperative APIs such as `queryClient.infiniteQuery`.\n * `options.queryKey` is required and is the query key to generate options for.\n *\n * @see {@link useInfiniteQuery} to run an infinite query with these options.\n * @param options - The {@link UndefinedInitialDataInfiniteOptions} to use — everything you can pass to\n * `useInfiniteQuery`.\n * @returns The same options object, typed so that `queryKey` carries the inferred data type.\n *\n * @example\n * ```vue\n * <script setup lang=\"ts\">\n * import { infiniteQueryOptions, useInfiniteQuery } from '@tanstack/vue-query'\n *\n * const projectsOptions = infiniteQueryOptions({\n * queryKey: ['projects'],\n * queryFn: ({ pageParam }) => fetchProjects(pageParam),\n * initialPageParam: 0,\n * getNextPageParam: (lastPage) => lastPage.nextId,\n * })\n *\n * const { data, isError, error, fetchNextPage } = useInfiniteQuery(projectsOptions)\n * </script>\n * ```\n */\nexport function infiniteQueryOptions<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: UndefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n): UndefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n> &\n QueryKeyWithDataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>\n\n/**\n * You can generally pass everything to `infiniteQueryOptions` that you can also pass to `useInfiniteQuery`.\n * These options can be shared across hooks and imperative APIs such as `queryClient.infiniteQuery`.\n * `options.queryKey` is required and is the query key to generate options for.\n *\n * This overload is selected when `initialData` is set, so the resulting `data` is never `undefined`.\n *\n * @see {@link useInfiniteQuery} to run an infinite query with these options.\n * @param options - The {@link DefinedInitialDataInfiniteOptions} to use — everything you can pass to\n * `useInfiniteQuery`, with `initialData` set.\n * @returns The same options object, typed so that `queryKey` carries the inferred data type.\n *\n * @example\n * ```vue\n * <script setup lang=\"ts\">\n * import { infiniteQueryOptions, useInfiniteQuery } from '@tanstack/vue-query'\n *\n * const projectsOptions = infiniteQueryOptions({\n * queryKey: ['projects'],\n * queryFn: ({ pageParam }) => fetchProjects(pageParam),\n * initialPageParam: 0,\n * getNextPageParam: (lastPage) => lastPage.nextId,\n * initialData: { pages: [], pageParams: [] },\n * })\n *\n * // `data` is never `undefined`, thanks to `initialData` — even if a refetch fails, so the\n * // list stays visible alongside the error.\n * const { data, isError, error } = useInfiniteQuery(projectsOptions)\n * </script>\n * ```\n */\nexport function infiniteQueryOptions<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: DefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n): DefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n> &\n QueryKeyWithDataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>\n\nexport function infiniteQueryOptions(options: unknown) {\n return options\n}\n"],"mappings":";AA+KA,SAAgB,qBAAqB,SAAkB;CACrD,OAAO;AACT"}
1
+ {"version":3,"file":"infiniteQueryOptions.js","names":[],"sources":["../../src/infiniteQueryOptions.ts"],"sourcesContent":["import type {\n DefaultError,\n InfiniteData,\n NonUndefinedGuard,\n QueryKey,\n QueryKeyWithDataTag,\n} from '@tanstack/query-core'\nimport type { UseInfiniteQueryOptions } from './useInfiniteQuery'\n\n/**\n * The options accepted by the `infiniteQueryOptions` overload selected when no `initialData` is set — `data`\n * may be `undefined` while the query is `pending`.\n *\n * @template TQueryFnData - The type of a single page, as your `queryFn` resolves it.\n * @template TError - The type of errors your `queryFn` may throw.\n * @template TData - The type `data` ends up as after `select` runs — defaults to `InfiniteData<TQueryFnData>`,\n * the shape of all fetched pages plus their page params.\n * @template TQueryKey - The type of your `queryKey`.\n * @template TPageParam - The type of the parameter passed to `queryFn` to fetch a given page.\n */\nexport type UndefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n> = UseInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n> & {\n initialData?: undefined\n}\n\n/**\n * The options accepted by the `infiniteQueryOptions` overload selected when `initialData` is set — `data` is\n * never `undefined` (unless a `select` changes `TData` to include `undefined`).\n *\n * @template TQueryFnData - The type of a single page, as your `queryFn` resolves it.\n * @template TError - The type of errors your `queryFn` may throw.\n * @template TData - The type `data` ends up as after `select` runs — defaults to `InfiniteData<TQueryFnData>`,\n * the shape of all fetched pages plus their page params.\n * @template TQueryKey - The type of your `queryKey`.\n * @template TPageParam - The type of the parameter passed to `queryFn` to fetch a given page.\n */\nexport type DefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n> = UseInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n> & {\n /**\n * If set, this value will be used as the initial data for the query cache (as long as the query hasn't been\n * created or cached yet). If set to a function, the function will be called **once** during the shared/root\n * query initialization, and be expected to synchronously return the initial data. Initial data is\n * considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the\n * cache.\n */\n initialData:\n | NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>\n | (() => NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>)\n}\n\n/**\n * You can generally pass everything to `infiniteQueryOptions` that you can also pass to `useInfiniteQuery`.\n * These options can be shared across hooks and imperative APIs such as `queryClient.infiniteQuery`.\n * `options.queryKey` is required and is the query key to generate options for.\n *\n * @see {@link useInfiniteQuery} to run an infinite query with these options.\n * @param options - The {@link UndefinedInitialDataInfiniteOptions} to use — everything you can pass to\n * `useInfiniteQuery`.\n * @returns The same options object, typed so that `queryKey` carries the inferred data type.\n *\n * @example\n * ```vue\n * <script setup lang=\"ts\">\n * import { infiniteQueryOptions, useInfiniteQuery } from '@tanstack/vue-query'\n *\n * const projectsOptions = infiniteQueryOptions({\n * queryKey: ['projects'],\n * queryFn: ({ pageParam }) => fetchProjects(pageParam),\n * initialPageParam: 0,\n * getNextPageParam: (lastPage) => lastPage.nextId,\n * })\n *\n * const { data, isError, error, fetchNextPage } = useInfiniteQuery(projectsOptions)\n * </script>\n * ```\n */\nexport function infiniteQueryOptions<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: UndefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n): UndefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n> &\n QueryKeyWithDataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>\n\n/**\n * You can generally pass everything to `infiniteQueryOptions` that you can also pass to `useInfiniteQuery`.\n * These options can be shared across hooks and imperative APIs such as `queryClient.infiniteQuery`.\n * `options.queryKey` is required and is the query key to generate options for.\n *\n * This overload is selected when `initialData` is set, so the resulting `data` is never `undefined` (unless\n * a `select` changes `TData` to include `undefined`).\n *\n * @see {@link useInfiniteQuery} to run an infinite query with these options.\n * @param options - The {@link DefinedInitialDataInfiniteOptions} to use — everything you can pass to\n * `useInfiniteQuery`, with `initialData` set.\n * @returns The same options object, typed so that `queryKey` carries the inferred data type.\n *\n * @example\n * ```vue\n * <script setup lang=\"ts\">\n * import { infiniteQueryOptions, useInfiniteQuery } from '@tanstack/vue-query'\n *\n * const projectsOptions = infiniteQueryOptions({\n * queryKey: ['projects'],\n * queryFn: ({ pageParam }) => fetchProjects(pageParam),\n * initialPageParam: 0,\n * getNextPageParam: (lastPage) => lastPage.nextId,\n * initialData: { pages: [], pageParams: [] },\n * })\n *\n * // `data` is never `undefined`, thanks to `initialData` — even if a refetch fails, so the\n * // list stays visible alongside the error.\n * const { data, isError, error } = useInfiniteQuery(projectsOptions)\n * </script>\n * ```\n */\nexport function infiniteQueryOptions<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: DefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n): DefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n> &\n QueryKeyWithDataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>\n\nexport function infiniteQueryOptions(options: unknown) {\n return options\n}\n"],"mappings":";AAgLA,SAAgB,qBAAqB,SAAkB;CACrD,OAAO;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"mutationCache.d.cts","names":[],"sources":["../../src/mutationCache.ts"],"mappings":";;;;;;;;cAca,sBAAsB;EACjC,KACE,iBACA,SAAS,cACT,kBACA,2BAEA,SAAS,aAAa,mBACrB,SAAS,OAAO,QAAQ,YAAY;EAIvC,QAAQ,UAAS,aAAa,mBAAwB,MAAM"}
1
+ {"version":3,"file":"mutationCache.d.cts","names":["MC"],"sources":["../../src/mutationCache.ts"],"mappings":";;;;;;;;cAca,sBAAsBA;EACjC,KACE,iBACA,SAAS,cACT,kBACA,2BAEA,SAAS,aAAa,mBACrB,SAAS,OAAO,QAAQ,YAAY;EAIvC,QAAQ,UAAS,aAAa,mBAAwB,MAAM"}
@@ -1 +1 @@
1
- {"version":3,"file":"mutationCache.d.ts","names":[],"sources":["../../src/mutationCache.ts"],"mappings":";;;;;;;;cAca,sBAAsB;EACjC,KACE,iBACA,SAAS,cACT,kBACA,2BAEA,SAAS,aAAa,mBACrB,SAAS,OAAO,QAAQ,YAAY;EAIvC,QAAQ,UAAS,aAAa,mBAAwB,MAAM"}
1
+ {"version":3,"file":"mutationCache.d.ts","names":["MC"],"sources":["../../src/mutationCache.ts"],"mappings":";;;;;;;;cAca,sBAAsBA;EACjC,KACE,iBACA,SAAS,cACT,kBACA,2BAEA,SAAS,aAAa,mBACrB,SAAS,OAAO,QAAQ,YAAY;EAIvC,QAAQ,UAAS,aAAa,mBAAwB,MAAM"}