@tanstack/vue-query 5.101.4 → 5.102.0

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 (355) hide show
  1. package/README.md +17 -0
  2. package/build/legacy/devtools/devtools.cjs +203 -258
  3. package/build/legacy/devtools/devtools.cjs.map +1 -1
  4. package/build/legacy/devtools/devtools.d.cts +6 -1
  5. package/build/legacy/devtools/devtools.d.cts.map +1 -0
  6. package/build/legacy/devtools/devtools.d.ts +6 -1
  7. package/build/legacy/devtools/devtools.d.ts.map +1 -0
  8. package/build/legacy/devtools/devtools.js +200 -236
  9. package/build/legacy/devtools/devtools.js.map +1 -1
  10. package/build/legacy/devtools/utils.cjs +37 -94
  11. package/build/legacy/devtools/utils.cjs.map +1 -1
  12. package/build/legacy/devtools/utils.d.cts +18 -5
  13. package/build/legacy/devtools/utils.d.cts.map +1 -0
  14. package/build/legacy/devtools/utils.d.ts +18 -5
  15. package/build/legacy/devtools/utils.d.ts.map +1 -0
  16. package/build/legacy/devtools/utils.js +32 -65
  17. package/build/legacy/devtools/utils.js.map +1 -1
  18. package/build/legacy/index.cjs +44 -83
  19. package/build/legacy/index.d.cts +17 -173
  20. package/build/legacy/index.d.ts +17 -173
  21. package/build/legacy/index.js +6 -27
  22. package/build/legacy/infiniteQueryOptions.cjs +6 -30
  23. package/build/legacy/infiniteQueryOptions.cjs.map +1 -1
  24. package/build/legacy/infiniteQueryOptions.d.cts +2 -3
  25. package/build/legacy/infiniteQueryOptions.d.ts +2 -3
  26. package/build/legacy/infiniteQueryOptions.js +5 -5
  27. package/build/legacy/infiniteQueryOptions.js.map +1 -1
  28. package/build/legacy/mutationCache.cjs +13 -37
  29. package/build/legacy/mutationCache.cjs.map +1 -1
  30. package/build/legacy/mutationCache.d.cts +10 -1
  31. package/build/legacy/mutationCache.d.cts.map +1 -0
  32. package/build/legacy/mutationCache.d.ts +10 -1
  33. package/build/legacy/mutationCache.d.ts.map +1 -0
  34. package/build/legacy/mutationCache.js +12 -12
  35. package/build/legacy/mutationCache.js.map +1 -1
  36. package/build/legacy/mutationOptions.cjs +6 -30
  37. package/build/legacy/mutationOptions.cjs.map +1 -1
  38. package/build/legacy/mutationOptions.d.cts +10 -1
  39. package/build/legacy/mutationOptions.d.cts.map +1 -0
  40. package/build/legacy/mutationOptions.d.ts +10 -1
  41. package/build/legacy/mutationOptions.d.ts.map +1 -0
  42. package/build/legacy/mutationOptions.js +5 -5
  43. package/build/legacy/mutationOptions.js.map +1 -1
  44. package/build/legacy/queryCache.cjs +13 -37
  45. package/build/legacy/queryCache.cjs.map +1 -1
  46. package/build/legacy/queryCache.d.cts +10 -1
  47. package/build/legacy/queryCache.d.cts.map +1 -0
  48. package/build/legacy/queryCache.d.ts +10 -1
  49. package/build/legacy/queryCache.d.ts.map +1 -0
  50. package/build/legacy/queryCache.js +12 -12
  51. package/build/legacy/queryCache.js.map +1 -1
  52. package/build/legacy/queryClient-C07d0chJ.d.cts +97 -0
  53. package/build/legacy/queryClient-C07d0chJ.d.cts.map +1 -0
  54. package/build/legacy/queryClient-hf6i_vCa.d.ts +97 -0
  55. package/build/legacy/queryClient-hf6i_vCa.d.ts.map +1 -0
  56. package/build/legacy/queryClient.cjs +104 -142
  57. package/build/legacy/queryClient.cjs.map +1 -1
  58. package/build/legacy/queryClient.d.cts +2 -1
  59. package/build/legacy/queryClient.d.ts +2 -1
  60. package/build/legacy/queryClient.js +103 -117
  61. package/build/legacy/queryClient.js.map +1 -1
  62. package/build/legacy/queryOptions.cjs +6 -30
  63. package/build/legacy/queryOptions.cjs.map +1 -1
  64. package/build/legacy/queryOptions.d.cts +19 -4
  65. package/build/legacy/queryOptions.d.cts.map +1 -0
  66. package/build/legacy/queryOptions.d.ts +19 -4
  67. package/build/legacy/queryOptions.d.ts.map +1 -0
  68. package/build/legacy/queryOptions.js +5 -5
  69. package/build/legacy/queryOptions.js.map +1 -1
  70. package/build/legacy/types-BzZi3_rS.d.cts +33 -0
  71. package/build/legacy/types-BzZi3_rS.d.cts.map +1 -0
  72. package/build/legacy/types-BzZi3_rS.d.ts +33 -0
  73. package/build/legacy/types-BzZi3_rS.d.ts.map +1 -0
  74. package/build/legacy/types.cjs +0 -19
  75. package/build/legacy/types.d.cts +2 -11
  76. package/build/legacy/types.d.ts +2 -11
  77. package/build/legacy/types.js +1 -1
  78. package/build/legacy/useBaseQuery.cjs +78 -140
  79. package/build/legacy/useBaseQuery.cjs.map +1 -1
  80. package/build/legacy/useBaseQuery.d.cts +2 -2
  81. package/build/legacy/useBaseQuery.d.ts +2 -2
  82. package/build/legacy/useBaseQuery.js +76 -124
  83. package/build/legacy/useBaseQuery.js.map +1 -1
  84. package/build/legacy/useInfiniteQuery.cjs +8 -36
  85. package/build/legacy/useInfiniteQuery.cjs.map +1 -1
  86. package/build/legacy/useInfiniteQuery.d.cts +2 -3
  87. package/build/legacy/useInfiniteQuery.d.ts +2 -3
  88. package/build/legacy/useInfiniteQuery.js +6 -10
  89. package/build/legacy/useInfiniteQuery.js.map +1 -1
  90. package/build/legacy/useIsFetching.cjs +23 -51
  91. package/build/legacy/useIsFetching.cjs.map +1 -1
  92. package/build/legacy/useIsFetching.d.cts +10 -2
  93. package/build/legacy/useIsFetching.d.cts.map +1 -0
  94. package/build/legacy/useIsFetching.d.ts +10 -2
  95. package/build/legacy/useIsFetching.d.ts.map +1 -0
  96. package/build/legacy/useIsFetching.js +21 -25
  97. package/build/legacy/useIsFetching.js.map +1 -1
  98. package/build/legacy/useMutation.cjs +42 -76
  99. package/build/legacy/useMutation.cjs.map +1 -1
  100. package/build/legacy/useMutation.d.cts +17 -3
  101. package/build/legacy/useMutation.d.cts.map +1 -0
  102. package/build/legacy/useMutation.d.ts +17 -3
  103. package/build/legacy/useMutation.d.ts.map +1 -0
  104. package/build/legacy/useMutation.js +39 -59
  105. package/build/legacy/useMutation.js.map +1 -1
  106. package/build/legacy/useMutationState.cjs +38 -75
  107. package/build/legacy/useMutationState.cjs.map +1 -1
  108. package/build/legacy/useMutationState.d.cts +16 -4
  109. package/build/legacy/useMutationState.d.cts.map +1 -0
  110. package/build/legacy/useMutationState.d.ts +16 -4
  111. package/build/legacy/useMutationState.d.ts.map +1 -0
  112. package/build/legacy/useMutationState.js +35 -55
  113. package/build/legacy/useMutationState.js.map +1 -1
  114. package/build/legacy/usePrefetchInfiniteQuery.cjs +19 -50
  115. package/build/legacy/usePrefetchInfiniteQuery.cjs.map +1 -1
  116. package/build/legacy/usePrefetchInfiniteQuery.d.cts +11 -2
  117. package/build/legacy/usePrefetchInfiniteQuery.d.cts.map +1 -0
  118. package/build/legacy/usePrefetchInfiniteQuery.d.ts +11 -2
  119. package/build/legacy/usePrefetchInfiniteQuery.d.ts.map +1 -0
  120. package/build/legacy/usePrefetchInfiniteQuery.js +17 -24
  121. package/build/legacy/usePrefetchInfiniteQuery.js.map +1 -1
  122. package/build/legacy/usePrefetchQuery.cjs +19 -48
  123. package/build/legacy/usePrefetchQuery.cjs.map +1 -1
  124. package/build/legacy/usePrefetchQuery.d.cts +11 -2
  125. package/build/legacy/usePrefetchQuery.d.cts.map +1 -0
  126. package/build/legacy/usePrefetchQuery.d.ts +11 -2
  127. package/build/legacy/usePrefetchQuery.d.ts.map +1 -0
  128. package/build/legacy/usePrefetchQuery.js +17 -22
  129. package/build/legacy/usePrefetchQuery.js.map +1 -1
  130. package/build/legacy/useQueries.cjs +57 -113
  131. package/build/legacy/useQueries.cjs.map +1 -1
  132. package/build/legacy/useQueries.d.cts +63 -3
  133. package/build/legacy/useQueries.d.cts.map +1 -0
  134. package/build/legacy/useQueries.d.ts +63 -3
  135. package/build/legacy/useQueries.d.ts.map +1 -0
  136. package/build/legacy/useQueries.js +55 -96
  137. package/build/legacy/useQueries.js.map +1 -1
  138. package/build/legacy/useQuery.cjs +8 -32
  139. package/build/legacy/useQuery.cjs.map +1 -1
  140. package/build/legacy/useQuery.d.cts +2 -6
  141. package/build/legacy/useQuery.d.ts +2 -6
  142. package/build/legacy/useQuery.js +6 -6
  143. package/build/legacy/useQuery.js.map +1 -1
  144. package/build/legacy/useQueryClient.cjs +12 -44
  145. package/build/legacy/useQueryClient.cjs.map +1 -1
  146. package/build/legacy/useQueryClient.d.cts +6 -1
  147. package/build/legacy/useQueryClient.d.cts.map +1 -0
  148. package/build/legacy/useQueryClient.d.ts +6 -1
  149. package/build/legacy/useQueryClient.d.ts.map +1 -0
  150. package/build/legacy/useQueryClient.js +10 -18
  151. package/build/legacy/useQueryClient.js.map +1 -1
  152. package/build/legacy/utils.cjs +40 -89
  153. package/build/legacy/utils.cjs.map +1 -1
  154. package/build/legacy/utils.d.cts +11 -6
  155. package/build/legacy/utils.d.cts.map +1 -0
  156. package/build/legacy/utils.d.ts +11 -6
  157. package/build/legacy/utils.d.ts.map +1 -0
  158. package/build/legacy/utils.js +32 -57
  159. package/build/legacy/utils.js.map +1 -1
  160. package/build/legacy/vueQueryPlugin.cjs +61 -103
  161. package/build/legacy/vueQueryPlugin.cjs.map +1 -1
  162. package/build/legacy/vueQueryPlugin.d.cts +23 -2
  163. package/build/legacy/vueQueryPlugin.d.cts.map +1 -0
  164. package/build/legacy/vueQueryPlugin.d.ts +23 -2
  165. package/build/legacy/vueQueryPlugin.d.ts.map +1 -0
  166. package/build/legacy/vueQueryPlugin.js +59 -77
  167. package/build/legacy/vueQueryPlugin.js.map +1 -1
  168. package/build/modern/devtools/devtools.cjs +201 -256
  169. package/build/modern/devtools/devtools.cjs.map +1 -1
  170. package/build/modern/devtools/devtools.d.cts +6 -1
  171. package/build/modern/devtools/devtools.d.cts.map +1 -0
  172. package/build/modern/devtools/devtools.d.ts +6 -1
  173. package/build/modern/devtools/devtools.d.ts.map +1 -0
  174. package/build/modern/devtools/devtools.js +198 -234
  175. package/build/modern/devtools/devtools.js.map +1 -1
  176. package/build/modern/devtools/utils.cjs +37 -94
  177. package/build/modern/devtools/utils.cjs.map +1 -1
  178. package/build/modern/devtools/utils.d.cts +18 -5
  179. package/build/modern/devtools/utils.d.cts.map +1 -0
  180. package/build/modern/devtools/utils.d.ts +18 -5
  181. package/build/modern/devtools/utils.d.ts.map +1 -0
  182. package/build/modern/devtools/utils.js +32 -65
  183. package/build/modern/devtools/utils.js.map +1 -1
  184. package/build/modern/index.cjs +44 -83
  185. package/build/modern/index.d.cts +17 -173
  186. package/build/modern/index.d.ts +17 -173
  187. package/build/modern/index.js +6 -27
  188. package/build/modern/infiniteQueryOptions.cjs +6 -30
  189. package/build/modern/infiniteQueryOptions.cjs.map +1 -1
  190. package/build/modern/infiniteQueryOptions.d.cts +2 -3
  191. package/build/modern/infiniteQueryOptions.d.ts +2 -3
  192. package/build/modern/infiniteQueryOptions.js +5 -5
  193. package/build/modern/infiniteQueryOptions.js.map +1 -1
  194. package/build/modern/mutationCache.cjs +13 -37
  195. package/build/modern/mutationCache.cjs.map +1 -1
  196. package/build/modern/mutationCache.d.cts +10 -1
  197. package/build/modern/mutationCache.d.cts.map +1 -0
  198. package/build/modern/mutationCache.d.ts +10 -1
  199. package/build/modern/mutationCache.d.ts.map +1 -0
  200. package/build/modern/mutationCache.js +12 -12
  201. package/build/modern/mutationCache.js.map +1 -1
  202. package/build/modern/mutationOptions.cjs +6 -30
  203. package/build/modern/mutationOptions.cjs.map +1 -1
  204. package/build/modern/mutationOptions.d.cts +10 -1
  205. package/build/modern/mutationOptions.d.cts.map +1 -0
  206. package/build/modern/mutationOptions.d.ts +10 -1
  207. package/build/modern/mutationOptions.d.ts.map +1 -0
  208. package/build/modern/mutationOptions.js +5 -5
  209. package/build/modern/mutationOptions.js.map +1 -1
  210. package/build/modern/queryCache.cjs +13 -37
  211. package/build/modern/queryCache.cjs.map +1 -1
  212. package/build/modern/queryCache.d.cts +10 -1
  213. package/build/modern/queryCache.d.cts.map +1 -0
  214. package/build/modern/queryCache.d.ts +10 -1
  215. package/build/modern/queryCache.d.ts.map +1 -0
  216. package/build/modern/queryCache.js +12 -12
  217. package/build/modern/queryCache.js.map +1 -1
  218. package/build/modern/queryClient-C07d0chJ.d.cts +97 -0
  219. package/build/modern/queryClient-C07d0chJ.d.cts.map +1 -0
  220. package/build/modern/queryClient-hf6i_vCa.d.ts +97 -0
  221. package/build/modern/queryClient-hf6i_vCa.d.ts.map +1 -0
  222. package/build/modern/queryClient.cjs +104 -142
  223. package/build/modern/queryClient.cjs.map +1 -1
  224. package/build/modern/queryClient.d.cts +2 -1
  225. package/build/modern/queryClient.d.ts +2 -1
  226. package/build/modern/queryClient.js +103 -117
  227. package/build/modern/queryClient.js.map +1 -1
  228. package/build/modern/queryOptions.cjs +6 -30
  229. package/build/modern/queryOptions.cjs.map +1 -1
  230. package/build/modern/queryOptions.d.cts +19 -4
  231. package/build/modern/queryOptions.d.cts.map +1 -0
  232. package/build/modern/queryOptions.d.ts +19 -4
  233. package/build/modern/queryOptions.d.ts.map +1 -0
  234. package/build/modern/queryOptions.js +5 -5
  235. package/build/modern/queryOptions.js.map +1 -1
  236. package/build/modern/types-BzZi3_rS.d.cts +33 -0
  237. package/build/modern/types-BzZi3_rS.d.cts.map +1 -0
  238. package/build/modern/types-BzZi3_rS.d.ts +33 -0
  239. package/build/modern/types-BzZi3_rS.d.ts.map +1 -0
  240. package/build/modern/types.cjs +0 -19
  241. package/build/modern/types.d.cts +2 -11
  242. package/build/modern/types.d.ts +2 -11
  243. package/build/modern/types.js +1 -1
  244. package/build/modern/useBaseQuery.cjs +77 -139
  245. package/build/modern/useBaseQuery.cjs.map +1 -1
  246. package/build/modern/useBaseQuery.d.cts +2 -2
  247. package/build/modern/useBaseQuery.d.ts +2 -2
  248. package/build/modern/useBaseQuery.js +75 -123
  249. package/build/modern/useBaseQuery.js.map +1 -1
  250. package/build/modern/useInfiniteQuery.cjs +8 -36
  251. package/build/modern/useInfiniteQuery.cjs.map +1 -1
  252. package/build/modern/useInfiniteQuery.d.cts +2 -3
  253. package/build/modern/useInfiniteQuery.d.ts +2 -3
  254. package/build/modern/useInfiniteQuery.js +6 -10
  255. package/build/modern/useInfiniteQuery.js.map +1 -1
  256. package/build/modern/useIsFetching.cjs +23 -51
  257. package/build/modern/useIsFetching.cjs.map +1 -1
  258. package/build/modern/useIsFetching.d.cts +10 -2
  259. package/build/modern/useIsFetching.d.cts.map +1 -0
  260. package/build/modern/useIsFetching.d.ts +10 -2
  261. package/build/modern/useIsFetching.d.ts.map +1 -0
  262. package/build/modern/useIsFetching.js +21 -25
  263. package/build/modern/useIsFetching.js.map +1 -1
  264. package/build/modern/useMutation.cjs +42 -76
  265. package/build/modern/useMutation.cjs.map +1 -1
  266. package/build/modern/useMutation.d.cts +17 -3
  267. package/build/modern/useMutation.d.cts.map +1 -0
  268. package/build/modern/useMutation.d.ts +17 -3
  269. package/build/modern/useMutation.d.ts.map +1 -0
  270. package/build/modern/useMutation.js +39 -59
  271. package/build/modern/useMutation.js.map +1 -1
  272. package/build/modern/useMutationState.cjs +38 -75
  273. package/build/modern/useMutationState.cjs.map +1 -1
  274. package/build/modern/useMutationState.d.cts +16 -4
  275. package/build/modern/useMutationState.d.cts.map +1 -0
  276. package/build/modern/useMutationState.d.ts +16 -4
  277. package/build/modern/useMutationState.d.ts.map +1 -0
  278. package/build/modern/useMutationState.js +35 -55
  279. package/build/modern/useMutationState.js.map +1 -1
  280. package/build/modern/usePrefetchInfiniteQuery.cjs +19 -50
  281. package/build/modern/usePrefetchInfiniteQuery.cjs.map +1 -1
  282. package/build/modern/usePrefetchInfiniteQuery.d.cts +11 -2
  283. package/build/modern/usePrefetchInfiniteQuery.d.cts.map +1 -0
  284. package/build/modern/usePrefetchInfiniteQuery.d.ts +11 -2
  285. package/build/modern/usePrefetchInfiniteQuery.d.ts.map +1 -0
  286. package/build/modern/usePrefetchInfiniteQuery.js +17 -24
  287. package/build/modern/usePrefetchInfiniteQuery.js.map +1 -1
  288. package/build/modern/usePrefetchQuery.cjs +19 -48
  289. package/build/modern/usePrefetchQuery.cjs.map +1 -1
  290. package/build/modern/usePrefetchQuery.d.cts +11 -2
  291. package/build/modern/usePrefetchQuery.d.cts.map +1 -0
  292. package/build/modern/usePrefetchQuery.d.ts +11 -2
  293. package/build/modern/usePrefetchQuery.d.ts.map +1 -0
  294. package/build/modern/usePrefetchQuery.js +17 -22
  295. package/build/modern/usePrefetchQuery.js.map +1 -1
  296. package/build/modern/useQueries.cjs +56 -112
  297. package/build/modern/useQueries.cjs.map +1 -1
  298. package/build/modern/useQueries.d.cts +63 -3
  299. package/build/modern/useQueries.d.cts.map +1 -0
  300. package/build/modern/useQueries.d.ts +63 -3
  301. package/build/modern/useQueries.d.ts.map +1 -0
  302. package/build/modern/useQueries.js +54 -95
  303. package/build/modern/useQueries.js.map +1 -1
  304. package/build/modern/useQuery.cjs +8 -32
  305. package/build/modern/useQuery.cjs.map +1 -1
  306. package/build/modern/useQuery.d.cts +2 -6
  307. package/build/modern/useQuery.d.ts +2 -6
  308. package/build/modern/useQuery.js +6 -6
  309. package/build/modern/useQuery.js.map +1 -1
  310. package/build/modern/useQueryClient.cjs +12 -44
  311. package/build/modern/useQueryClient.cjs.map +1 -1
  312. package/build/modern/useQueryClient.d.cts +6 -1
  313. package/build/modern/useQueryClient.d.cts.map +1 -0
  314. package/build/modern/useQueryClient.d.ts +6 -1
  315. package/build/modern/useQueryClient.d.ts.map +1 -0
  316. package/build/modern/useQueryClient.js +10 -18
  317. package/build/modern/useQueryClient.js.map +1 -1
  318. package/build/modern/utils.cjs +40 -89
  319. package/build/modern/utils.cjs.map +1 -1
  320. package/build/modern/utils.d.cts +11 -6
  321. package/build/modern/utils.d.cts.map +1 -0
  322. package/build/modern/utils.d.ts +11 -6
  323. package/build/modern/utils.d.ts.map +1 -0
  324. package/build/modern/utils.js +32 -57
  325. package/build/modern/utils.js.map +1 -1
  326. package/build/modern/vueQueryPlugin.cjs +60 -102
  327. package/build/modern/vueQueryPlugin.cjs.map +1 -1
  328. package/build/modern/vueQueryPlugin.d.cts +23 -2
  329. package/build/modern/vueQueryPlugin.d.cts.map +1 -0
  330. package/build/modern/vueQueryPlugin.d.ts +23 -2
  331. package/build/modern/vueQueryPlugin.d.ts.map +1 -0
  332. package/build/modern/vueQueryPlugin.js +58 -76
  333. package/build/modern/vueQueryPlugin.js.map +1 -1
  334. package/package.json +5 -7
  335. package/src/index.ts +5 -1
  336. package/src/infiniteQueryOptions.ts +5 -7
  337. package/src/queryClient.ts +150 -36
  338. package/src/queryOptions.ts +32 -14
  339. package/src/useMutation.ts +4 -4
  340. package/src/useMutationState.ts +33 -8
  341. package/src/usePrefetchInfiniteQuery.ts +22 -42
  342. package/src/usePrefetchQuery.ts +29 -5
  343. package/src/useQuery.ts +19 -9
  344. package/build/legacy/_tsup-dts-rollup.d.cts +0 -884
  345. package/build/legacy/_tsup-dts-rollup.d.ts +0 -884
  346. package/build/legacy/index.cjs.map +0 -1
  347. package/build/legacy/index.js.map +0 -1
  348. package/build/legacy/types.cjs.map +0 -1
  349. package/build/legacy/types.js.map +0 -1
  350. package/build/modern/_tsup-dts-rollup.d.cts +0 -884
  351. package/build/modern/_tsup-dts-rollup.d.ts +0 -884
  352. package/build/modern/index.cjs.map +0 -1
  353. package/build/modern/index.js.map +0 -1
  354. package/build/modern/types.cjs.map +0 -1
  355. package/build/modern/types.js.map +0 -1
@@ -1,79 +1,61 @@
1
- // src/vueQueryPlugin.ts
2
- import { isVue2 } from "vue-demi";
3
- import { environmentManager } from "@tanstack/query-core";
4
- import { QueryClient } from "./queryClient.js";
5
1
  import { getClientKey } from "./utils.js";
2
+ import { QueryClient as QueryClient$1 } from "./queryClient.js";
6
3
  import { setupDevtools } from "./devtools/devtools.js";
7
- var VueQueryPlugin = {
8
- install: (app, options = {}) => {
9
- const clientKey = getClientKey(options.queryClientKey);
10
- let client;
11
- if ("queryClient" in options && options.queryClient) {
12
- client = options.queryClient;
13
- } else {
14
- const clientConfig = "queryClientConfig" in options ? options.queryClientConfig : void 0;
15
- client = new QueryClient(clientConfig);
16
- }
17
- if (!environmentManager.isServer()) {
18
- client.mount();
19
- }
20
- let persisterUnmount = () => {
21
- };
22
- if (options.clientPersister) {
23
- if (client.isRestoring) {
24
- client.isRestoring.value = true;
25
- }
26
- const [unmount, promise] = options.clientPersister(client);
27
- persisterUnmount = unmount;
28
- promise.then(() => {
29
- if (client.isRestoring) {
30
- client.isRestoring.value = false;
31
- }
32
- options.clientPersisterOnSuccess?.(client);
33
- });
34
- }
35
- const cleanup = () => {
36
- client.unmount();
37
- persisterUnmount();
38
- };
39
- if (app.onUnmount) {
40
- app.onUnmount(cleanup);
41
- } else {
42
- const originalUnmount = app.unmount;
43
- app.unmount = function vueQueryUnmount() {
44
- cleanup();
45
- originalUnmount();
46
- };
47
- }
48
- if (isVue2) {
49
- app.mixin({
50
- beforeCreate() {
51
- if (!this._provided) {
52
- const provideCache = {};
53
- Object.defineProperty(this, "_provided", {
54
- get: () => provideCache,
55
- set: (v) => Object.assign(provideCache, v)
56
- });
57
- }
58
- this._provided[clientKey] = client;
59
- if (process.env.NODE_ENV === "development") {
60
- if (this === this.$root && options.enableDevtoolsV6Plugin) {
61
- setupDevtools(this, client);
62
- }
63
- }
64
- }
65
- });
66
- } else {
67
- app.provide(clientKey, client);
68
- if (process.env.NODE_ENV === "development") {
69
- if (options.enableDevtoolsV6Plugin) {
70
- setupDevtools(app, client);
71
- }
72
- }
73
- }
74
- }
75
- };
76
- export {
77
- VueQueryPlugin
78
- };
4
+ import { environmentManager } from "@tanstack/query-core";
5
+ import { isVue2 } from "vue-demi";
6
+ //#region src/vueQueryPlugin.ts
7
+ const VueQueryPlugin = { install: (app, options = {}) => {
8
+ const clientKey = getClientKey(options.queryClientKey);
9
+ let client;
10
+ if ("queryClient" in options && options.queryClient) client = options.queryClient;
11
+ else {
12
+ const clientConfig = "queryClientConfig" in options ? options.queryClientConfig : void 0;
13
+ client = new QueryClient$1(clientConfig);
14
+ }
15
+ if (!environmentManager.isServer()) client.mount();
16
+ let persisterUnmount = () => {};
17
+ if (options.clientPersister) {
18
+ if (client.isRestoring) client.isRestoring.value = true;
19
+ const [unmount, promise] = options.clientPersister(client);
20
+ persisterUnmount = unmount;
21
+ promise.then(() => {
22
+ if (client.isRestoring) client.isRestoring.value = false;
23
+ options.clientPersisterOnSuccess?.(client);
24
+ });
25
+ }
26
+ const cleanup = () => {
27
+ client.unmount();
28
+ persisterUnmount();
29
+ };
30
+ if (app.onUnmount) app.onUnmount(cleanup);
31
+ else {
32
+ const originalUnmount = app.unmount;
33
+ app.unmount = function vueQueryUnmount() {
34
+ cleanup();
35
+ originalUnmount();
36
+ };
37
+ }
38
+ if (isVue2) app.mixin({ beforeCreate() {
39
+ if (!this._provided) {
40
+ const provideCache = {};
41
+ Object.defineProperty(this, "_provided", {
42
+ get: () => provideCache,
43
+ set: (v) => Object.assign(provideCache, v)
44
+ });
45
+ }
46
+ this._provided[clientKey] = client;
47
+ if (process.env.NODE_ENV === "development") {
48
+ if (this === this.$root && options.enableDevtoolsV6Plugin) setupDevtools(this, client);
49
+ }
50
+ } });
51
+ else {
52
+ app.provide(clientKey, client);
53
+ if (process.env.NODE_ENV === "development") {
54
+ if (options.enableDevtoolsV6Plugin) setupDevtools(app, client);
55
+ }
56
+ }
57
+ } };
58
+ //#endregion
59
+ export { VueQueryPlugin };
60
+
79
61
  //# sourceMappingURL=vueQueryPlugin.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/vueQueryPlugin.ts"],"sourcesContent":["import { isVue2 } from 'vue-demi'\nimport { environmentManager } from '@tanstack/query-core'\n\nimport { QueryClient } from './queryClient'\nimport { getClientKey } from './utils'\nimport { setupDevtools } from './devtools/devtools'\nimport type { QueryClientConfig } from './types'\n\ntype ClientPersister = (client: QueryClient) => [() => void, Promise<void>]\n\ninterface CommonOptions {\n enableDevtoolsV6Plugin?: boolean\n queryClientKey?: string\n clientPersister?: ClientPersister\n clientPersisterOnSuccess?: (client: QueryClient) => void\n}\n\ninterface ConfigOptions extends CommonOptions {\n queryClientConfig?: QueryClientConfig\n}\n\ninterface ClientOptions extends CommonOptions {\n queryClient?: QueryClient\n}\n\nexport type VueQueryPluginOptions = ConfigOptions | ClientOptions\n\nexport const VueQueryPlugin = {\n install: (app: any, options: VueQueryPluginOptions = {}) => {\n const clientKey = getClientKey(options.queryClientKey)\n let client: QueryClient\n\n if ('queryClient' in options && options.queryClient) {\n client = options.queryClient\n } else {\n const clientConfig =\n 'queryClientConfig' in options ? options.queryClientConfig : undefined\n client = new QueryClient(clientConfig)\n }\n\n if (!environmentManager.isServer()) {\n client.mount()\n }\n\n let persisterUnmount = () => {\n // noop\n }\n\n if (options.clientPersister) {\n if (client.isRestoring) {\n client.isRestoring.value = true\n }\n const [unmount, promise] = options.clientPersister(client)\n persisterUnmount = unmount\n promise.then(() => {\n if (client.isRestoring) {\n client.isRestoring.value = false\n }\n options.clientPersisterOnSuccess?.(client)\n })\n }\n\n const cleanup = () => {\n client.unmount()\n persisterUnmount()\n }\n\n if (app.onUnmount) {\n app.onUnmount(cleanup)\n } else {\n const originalUnmount = app.unmount\n app.unmount = function vueQueryUnmount() {\n cleanup()\n originalUnmount()\n }\n }\n\n if (isVue2) {\n app.mixin({\n beforeCreate() {\n // HACK: taken from provide(): https://github.com/vuejs/composition-api/blob/master/src/apis/inject.ts#L30\n if (!this._provided) {\n const provideCache = {}\n Object.defineProperty(this, '_provided', {\n get: () => provideCache,\n set: (v) => Object.assign(provideCache, v),\n })\n }\n\n this._provided[clientKey] = client\n\n if (process.env.NODE_ENV === 'development') {\n if (this === this.$root && options.enableDevtoolsV6Plugin) {\n setupDevtools(this, client)\n }\n }\n },\n })\n } else {\n app.provide(clientKey, client)\n\n if (process.env.NODE_ENV === 'development') {\n if (options.enableDevtoolsV6Plugin) {\n setupDevtools(app, client)\n }\n }\n }\n },\n}\n"],"mappings":";AAAA,SAAS,cAAc;AACvB,SAAS,0BAA0B;AAEnC,SAAS,mBAAmB;AAC5B,SAAS,oBAAoB;AAC7B,SAAS,qBAAqB;AAsBvB,IAAM,iBAAiB;AAAA,EAC5B,SAAS,CAAC,KAAU,UAAiC,CAAC,MAAM;AAC1D,UAAM,YAAY,aAAa,QAAQ,cAAc;AACrD,QAAI;AAEJ,QAAI,iBAAiB,WAAW,QAAQ,aAAa;AACnD,eAAS,QAAQ;AAAA,IACnB,OAAO;AACL,YAAM,eACJ,uBAAuB,UAAU,QAAQ,oBAAoB;AAC/D,eAAS,IAAI,YAAY,YAAY;AAAA,IACvC;AAEA,QAAI,CAAC,mBAAmB,SAAS,GAAG;AAClC,aAAO,MAAM;AAAA,IACf;AAEA,QAAI,mBAAmB,MAAM;AAAA,IAE7B;AAEA,QAAI,QAAQ,iBAAiB;AAC3B,UAAI,OAAO,aAAa;AACtB,eAAO,YAAY,QAAQ;AAAA,MAC7B;AACA,YAAM,CAAC,SAAS,OAAO,IAAI,QAAQ,gBAAgB,MAAM;AACzD,yBAAmB;AACnB,cAAQ,KAAK,MAAM;AACjB,YAAI,OAAO,aAAa;AACtB,iBAAO,YAAY,QAAQ;AAAA,QAC7B;AACA,gBAAQ,2BAA2B,MAAM;AAAA,MAC3C,CAAC;AAAA,IACH;AAEA,UAAM,UAAU,MAAM;AACpB,aAAO,QAAQ;AACf,uBAAiB;AAAA,IACnB;AAEA,QAAI,IAAI,WAAW;AACjB,UAAI,UAAU,OAAO;AAAA,IACvB,OAAO;AACL,YAAM,kBAAkB,IAAI;AAC5B,UAAI,UAAU,SAAS,kBAAkB;AACvC,gBAAQ;AACR,wBAAgB;AAAA,MAClB;AAAA,IACF;AAEA,QAAI,QAAQ;AACV,UAAI,MAAM;AAAA,QACR,eAAe;AAEb,cAAI,CAAC,KAAK,WAAW;AACnB,kBAAM,eAAe,CAAC;AACtB,mBAAO,eAAe,MAAM,aAAa;AAAA,cACvC,KAAK,MAAM;AAAA,cACX,KAAK,CAAC,MAAM,OAAO,OAAO,cAAc,CAAC;AAAA,YAC3C,CAAC;AAAA,UACH;AAEA,eAAK,UAAU,SAAS,IAAI;AAE5B,cAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,gBAAI,SAAS,KAAK,SAAS,QAAQ,wBAAwB;AACzD,4BAAc,MAAM,MAAM;AAAA,YAC5B;AAAA,UACF;AAAA,QACF;AAAA,MACF,CAAC;AAAA,IACH,OAAO;AACL,UAAI,QAAQ,WAAW,MAAM;AAE7B,UAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,YAAI,QAAQ,wBAAwB;AAClC,wBAAc,KAAK,MAAM;AAAA,QAC3B;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"file":"vueQueryPlugin.js","names":["QueryClient"],"sources":["../../src/vueQueryPlugin.ts"],"sourcesContent":["import { isVue2 } from 'vue-demi'\nimport { environmentManager } from '@tanstack/query-core'\n\nimport { QueryClient } from './queryClient'\nimport { getClientKey } from './utils'\nimport { setupDevtools } from './devtools/devtools'\nimport type { QueryClientConfig } from './types'\n\ntype ClientPersister = (client: QueryClient) => [() => void, Promise<void>]\n\ninterface CommonOptions {\n enableDevtoolsV6Plugin?: boolean\n queryClientKey?: string\n clientPersister?: ClientPersister\n clientPersisterOnSuccess?: (client: QueryClient) => void\n}\n\ninterface ConfigOptions extends CommonOptions {\n queryClientConfig?: QueryClientConfig\n}\n\ninterface ClientOptions extends CommonOptions {\n queryClient?: QueryClient\n}\n\nexport type VueQueryPluginOptions = ConfigOptions | ClientOptions\n\nexport const VueQueryPlugin = {\n install: (app: any, options: VueQueryPluginOptions = {}) => {\n const clientKey = getClientKey(options.queryClientKey)\n let client: QueryClient\n\n if ('queryClient' in options && options.queryClient) {\n client = options.queryClient\n } else {\n const clientConfig =\n 'queryClientConfig' in options ? options.queryClientConfig : undefined\n client = new QueryClient(clientConfig)\n }\n\n if (!environmentManager.isServer()) {\n client.mount()\n }\n\n let persisterUnmount = () => {\n // noop\n }\n\n if (options.clientPersister) {\n if (client.isRestoring) {\n client.isRestoring.value = true\n }\n const [unmount, promise] = options.clientPersister(client)\n persisterUnmount = unmount\n promise.then(() => {\n if (client.isRestoring) {\n client.isRestoring.value = false\n }\n options.clientPersisterOnSuccess?.(client)\n })\n }\n\n const cleanup = () => {\n client.unmount()\n persisterUnmount()\n }\n\n if (app.onUnmount) {\n app.onUnmount(cleanup)\n } else {\n const originalUnmount = app.unmount\n app.unmount = function vueQueryUnmount() {\n cleanup()\n originalUnmount()\n }\n }\n\n if (isVue2) {\n app.mixin({\n beforeCreate() {\n // HACK: taken from provide(): https://github.com/vuejs/composition-api/blob/master/src/apis/inject.ts#L30\n if (!this._provided) {\n const provideCache = {}\n Object.defineProperty(this, '_provided', {\n get: () => provideCache,\n set: (v) => Object.assign(provideCache, v),\n })\n }\n\n this._provided[clientKey] = client\n\n if (process.env.NODE_ENV === 'development') {\n if (this === this.$root && options.enableDevtoolsV6Plugin) {\n setupDevtools(this, client)\n }\n }\n },\n })\n } else {\n app.provide(clientKey, client)\n\n if (process.env.NODE_ENV === 'development') {\n if (options.enableDevtoolsV6Plugin) {\n setupDevtools(app, client)\n }\n }\n }\n },\n}\n"],"mappings":";;;;;;AA2BA,MAAa,iBAAiB,EAC5B,UAAU,KAAU,UAAiC,CAAC,MAAM;CAC1D,MAAM,YAAY,aAAa,QAAQ,cAAc;CACrD,IAAI;CAEJ,IAAI,iBAAiB,WAAW,QAAQ,aACtC,SAAS,QAAQ;MACZ;EACL,MAAM,eACJ,uBAAuB,UAAU,QAAQ,oBAAoB,KAAA;EAC/D,SAAS,IAAIA,cAAY,YAAY;CACvC;CAEA,IAAI,CAAC,mBAAmB,SAAS,GAC/B,OAAO,MAAM;CAGf,IAAI,yBAAyB,CAE7B;CAEA,IAAI,QAAQ,iBAAiB;EAC3B,IAAI,OAAO,aACT,OAAO,YAAY,QAAQ;EAE7B,MAAM,CAAC,SAAS,WAAW,QAAQ,gBAAgB,MAAM;EACzD,mBAAmB;EACnB,QAAQ,WAAW;GACjB,IAAI,OAAO,aACT,OAAO,YAAY,QAAQ;GAE7B,QAAQ,2BAA2B,MAAM;EAC3C,CAAC;CACH;CAEA,MAAM,gBAAgB;EACpB,OAAO,QAAQ;EACf,iBAAiB;CACnB;CAEA,IAAI,IAAI,WACN,IAAI,UAAU,OAAO;MAChB;EACL,MAAM,kBAAkB,IAAI;EAC5B,IAAI,UAAU,SAAS,kBAAkB;GACvC,QAAQ;GACR,gBAAgB;EAClB;CACF;CAEA,IAAI,QACF,IAAI,MAAM,EACR,eAAe;EAEb,IAAI,CAAC,KAAK,WAAW;GACnB,MAAM,eAAe,CAAC;GACtB,OAAO,eAAe,MAAM,aAAa;IACvC,WAAW;IACX,MAAM,MAAM,OAAO,OAAO,cAAc,CAAC;GAC3C,CAAC;EACH;EAEA,KAAK,UAAU,aAAa;EAE5B,IAAI,QAAQ,IAAI,aAAa,eACvB;OAAA,SAAS,KAAK,SAAS,QAAQ,wBACjC,cAAc,MAAM,MAAM;EAAA;CAGhC,EACF,CAAC;MACI;EACL,IAAI,QAAQ,WAAW,MAAM;EAE7B,IAAI,QAAQ,IAAI,aAAa,eACvB;OAAA,QAAQ,wBACV,cAAc,KAAK,MAAM;EAAA;CAG/B;AACF,EACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/vue-query",
3
- "version": "5.101.4",
3
+ "version": "5.102.0",
4
4
  "description": "Hooks for managing, caching and syncing asynchronous and remote data in Vue",
5
5
  "author": "Damian Osipiuk",
6
6
  "license": "MIT",
@@ -42,7 +42,7 @@
42
42
  "@tanstack/match-sorter-utils": "^8.19.4",
43
43
  "@vue/devtools-api": "^6.6.3",
44
44
  "vue-demi": "^0.14.10",
45
- "@tanstack/query-core": "5.101.4"
45
+ "@tanstack/query-core": "5.102.0"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@vitejs/plugin-vue": "^5.2.4",
@@ -64,23 +64,21 @@
64
64
  },
65
65
  "scripts": {
66
66
  "clean": "premove ./build ./coverage ./dist-ts",
67
- "compile": "tsc --build",
67
+ "compile": "node ../../node_modules/typescript/lib/tsc.js --build",
68
68
  "test:eslint": "eslint --concurrency=auto ./src",
69
69
  "test:types": "vue-demi-switch 3 && pnpm run \"/^test:types:ts[0-9]{2}$/\"",
70
- "test:types:ts54": "node ../../node_modules/typescript54/lib/tsc.js --build tsconfig.legacy.json",
71
- "test:types:ts55": "node ../../node_modules/typescript55/lib/tsc.js --build tsconfig.legacy.json",
72
70
  "test:types:ts56": "node ../../node_modules/typescript56/lib/tsc.js --build tsconfig.legacy.json",
73
71
  "test:types:ts57": "node ../../node_modules/typescript57/lib/tsc.js --build tsconfig.legacy.json",
74
72
  "test:types:ts58": "node ../../node_modules/typescript58/lib/tsc.js --build tsconfig.legacy.json",
75
73
  "test:types:ts59": "node ../../node_modules/typescript59/lib/tsc.js --build tsconfig.legacy.json",
76
74
  "test:types:tscurrent": "tsc --build",
77
- "test:types:ts60": "node ../../node_modules/typescript60/lib/tsc.js --build tsconfig.legacy.json",
75
+ "test:types:ts70": "node ../../node_modules/typescript70/lib/tsc.js --build tsconfig.legacy.json",
78
76
  "test:lib": "pnpm run test:lib:2 && pnpm run test:lib:2.7 && pnpm run test:lib:3",
79
77
  "test:lib:2": "vue-demi-switch 2 vue2 && vitest",
80
78
  "test:lib:2.7": "vue-demi-switch 2.7 vue2.7 && vitest",
81
79
  "test:lib:3": "vue-demi-switch 3 && vitest",
82
80
  "test:lib:dev": "pnpm run test:lib --watch",
83
81
  "test:build": "publint --strict && attw --pack",
84
- "build": "tsup --tsconfig tsconfig.prod.json"
82
+ "build": "tsdown --tsconfig tsconfig.prod.json"
85
83
  }
86
84
  }
package/src/index.ts CHANGED
@@ -6,7 +6,11 @@ export { VueQueryPlugin } from './vueQueryPlugin'
6
6
  export { QueryClient } from './queryClient'
7
7
  export { QueryCache } from './queryCache'
8
8
  export { queryOptions } from './queryOptions'
9
- export { type QueryOptions } from './queryOptions'
9
+ export type {
10
+ QueryOptions,
11
+ UndefinedInitialQueryOptionsWithDataTag,
12
+ DefinedInitialQueryOptionsWithDataTag,
13
+ } from './queryOptions'
10
14
  export { infiniteQueryOptions } from './infiniteQueryOptions'
11
15
  export type {
12
16
  DefinedInitialDataInfiniteOptions,
@@ -1,9 +1,9 @@
1
1
  import type {
2
- DataTag,
3
2
  DefaultError,
4
3
  InfiniteData,
5
4
  NonUndefinedGuard,
6
5
  QueryKey,
6
+ QueryKeyWithDataTag,
7
7
  } from '@tanstack/query-core'
8
8
  import type { UseInfiniteQueryOptions } from './useInfiniteQuery'
9
9
 
@@ -61,9 +61,8 @@ export function infiniteQueryOptions<
61
61
  TData,
62
62
  TQueryKey,
63
63
  TPageParam
64
- > & {
65
- queryKey: DataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>
66
- }
64
+ > &
65
+ QueryKeyWithDataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>
67
66
 
68
67
  export function infiniteQueryOptions<
69
68
  TQueryFnData,
@@ -85,9 +84,8 @@ export function infiniteQueryOptions<
85
84
  TData,
86
85
  TQueryKey,
87
86
  TPageParam
88
- > & {
89
- queryKey: DataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>
90
- }
87
+ > &
88
+ QueryKeyWithDataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>
91
89
 
92
90
  export function infiniteQueryOptions(options: unknown) {
93
91
  return options
@@ -14,14 +14,15 @@ import type {
14
14
  FetchInfiniteQueryOptions,
15
15
  FetchQueryOptions,
16
16
  InferDataFromTag,
17
- InferErrorFromTag,
18
17
  InfiniteData,
18
+ InfiniteQueryExecuteOptions,
19
19
  InvalidateOptions,
20
20
  InvalidateQueryFilters,
21
21
  MutationFilters,
22
22
  MutationKey,
23
23
  MutationObserverOptions,
24
24
  OmitKeyof,
25
+ QueryExecuteOptions,
25
26
  QueryFilters,
26
27
  QueryKey,
27
28
  QueryObserverOptions,
@@ -65,6 +66,9 @@ export class QueryClient extends QC {
65
66
  return super.getQueryData(cloneDeepUnref(queryKey))
66
67
  }
67
68
 
69
+ /**
70
+ * @deprecated Use queryClient.query({ ...options, staleTime: 'static' }) instead. This method will be removed in the next major version.
71
+ */
68
72
  ensureQueryData<
69
73
  TQueryFnData,
70
74
  TError = DefaultError,
@@ -149,24 +153,14 @@ export class QueryClient extends QC {
149
153
  return super.getQueryState(cloneDeepUnref(queryKey))
150
154
  }
151
155
 
152
- removeQueries<
153
- TQueryFnData = unknown,
154
- TError = DefaultError,
155
- TTaggedQueryKey extends QueryKey = QueryKey,
156
- TInferredQueryFnData = InferDataFromTag<TQueryFnData, TTaggedQueryKey>,
157
- TInferredError = InferErrorFromTag<TError, TTaggedQueryKey>,
158
- >(filters?: QueryFilters<TTaggedQueryKey>): void
156
+ removeQueries<TTaggedQueryKey extends QueryKey = QueryKey>(
157
+ filters?: QueryFilters<TTaggedQueryKey>,
158
+ ): void
159
159
  removeQueries(filters: MaybeRefDeep<QueryFilters> = {}): void {
160
160
  return super.removeQueries(cloneDeepUnref(filters))
161
161
  }
162
162
 
163
- resetQueries<
164
- TQueryFnData = unknown,
165
- TError = DefaultError,
166
- TTaggedQueryKey extends QueryKey = QueryKey,
167
- TInferredQueryFnData = InferDataFromTag<TQueryFnData, TTaggedQueryKey>,
168
- TInferredError = InferErrorFromTag<TError, TTaggedQueryKey>,
169
- >(
163
+ resetQueries<TTaggedQueryKey extends QueryKey = QueryKey>(
170
164
  filters?: QueryFilters<TTaggedQueryKey>,
171
165
  options?: MaybeRefDeep<ResetOptions>,
172
166
  ): Promise<void>
@@ -177,13 +171,7 @@ export class QueryClient extends QC {
177
171
  return super.resetQueries(cloneDeepUnref(filters), cloneDeepUnref(options))
178
172
  }
179
173
 
180
- cancelQueries<
181
- TQueryFnData = unknown,
182
- TError = DefaultError,
183
- TTaggedQueryKey extends QueryKey = QueryKey,
184
- TInferredQueryFnData = InferDataFromTag<TQueryFnData, TTaggedQueryKey>,
185
- TInferredError = InferErrorFromTag<TError, TTaggedQueryKey>,
186
- >(
174
+ cancelQueries<TTaggedQueryKey extends QueryKey = QueryKey>(
187
175
  filters?: QueryFilters<TTaggedQueryKey>,
188
176
  options?: MaybeRefDeep<CancelOptions>,
189
177
  ): Promise<void>
@@ -194,13 +182,7 @@ export class QueryClient extends QC {
194
182
  return super.cancelQueries(cloneDeepUnref(filters), cloneDeepUnref(options))
195
183
  }
196
184
 
197
- invalidateQueries<
198
- TQueryFnData = unknown,
199
- TError = DefaultError,
200
- TTaggedQueryKey extends QueryKey = QueryKey,
201
- TInferredQueryFnData = InferDataFromTag<TQueryFnData, TTaggedQueryKey>,
202
- TInferredError = InferErrorFromTag<TError, TTaggedQueryKey>,
203
- >(
185
+ invalidateQueries<TTaggedQueryKey extends QueryKey = QueryKey>(
204
186
  filters?:
205
187
  | InvalidateQueryFilters<TTaggedQueryKey>
206
188
  | (() => InvalidateQueryFilters<TTaggedQueryKey>),
@@ -240,13 +222,7 @@ export class QueryClient extends QC {
240
222
  })
241
223
  }
242
224
 
243
- refetchQueries<
244
- TQueryFnData = unknown,
245
- TError = DefaultError,
246
- TTaggedQueryKey extends QueryKey = QueryKey,
247
- TInferredQueryFnData = InferDataFromTag<TQueryFnData, TTaggedQueryKey>,
248
- TInferredError = InferErrorFromTag<TError, TTaggedQueryKey>,
249
- >(
225
+ refetchQueries<TTaggedQueryKey extends QueryKey = QueryKey>(
250
226
  filters?: RefetchQueryFilters<TTaggedQueryKey>,
251
227
  options?: MaybeRefDeep<RefetchOptions>,
252
228
  ): Promise<void>
@@ -260,6 +236,69 @@ export class QueryClient extends QC {
260
236
  )
261
237
  }
262
238
 
239
+ // These one-shot imperative methods do not resolve top-level option getters.
240
+ // Resolve getters explicitly before calling, e.g. queryClient.query(options()).
241
+ query<
242
+ TQueryFnData,
243
+ TError = DefaultError,
244
+ TData = TQueryFnData,
245
+ TQueryData = TQueryFnData,
246
+ TQueryKey extends QueryKey = QueryKey,
247
+ TPageParam = never,
248
+ >(
249
+ options: QueryExecuteOptions<
250
+ TQueryFnData,
251
+ TError,
252
+ TData,
253
+ TQueryData,
254
+ TQueryKey,
255
+ TPageParam
256
+ >,
257
+ ): Promise<TData>
258
+ query<
259
+ TQueryFnData,
260
+ TError = DefaultError,
261
+ TData = TQueryFnData,
262
+ TQueryData = TQueryFnData,
263
+ TQueryKey extends QueryKey = QueryKey,
264
+ TPageParam = never,
265
+ >(
266
+ options: MaybeRefDeep<
267
+ QueryExecuteOptions<
268
+ TQueryFnData,
269
+ TError,
270
+ TData,
271
+ TQueryData,
272
+ TQueryKey,
273
+ TPageParam
274
+ >
275
+ >,
276
+ ): Promise<TData>
277
+ query<
278
+ TQueryFnData,
279
+ TError = DefaultError,
280
+ TData = TQueryFnData,
281
+ TQueryData = TQueryFnData,
282
+ TQueryKey extends QueryKey = QueryKey,
283
+ TPageParam = never,
284
+ >(
285
+ options: MaybeRefDeep<
286
+ QueryExecuteOptions<
287
+ TQueryFnData,
288
+ TError,
289
+ TData,
290
+ TQueryData,
291
+ TQueryKey,
292
+ TPageParam
293
+ >
294
+ >,
295
+ ): Promise<TData> {
296
+ return super.query(cloneDeepUnref(options))
297
+ }
298
+
299
+ /**
300
+ * @deprecated Use queryClient.query(options) instead. This method will be removed in the next major version.
301
+ */
263
302
  fetchQuery<
264
303
  TQueryFnData,
265
304
  TError = DefaultError,
@@ -308,6 +347,9 @@ export class QueryClient extends QC {
308
347
  return super.fetchQuery(cloneDeepUnref(options))
309
348
  }
310
349
 
350
+ /**
351
+ * @deprecated Use queryClient.query(options) instead. You can swallow errors with `.catch(noop)`. This method will be removed in the next major version.
352
+ */
311
353
  prefetchQuery<
312
354
  TQueryFnData = unknown,
313
355
  TError = DefaultError,
@@ -339,6 +381,75 @@ export class QueryClient extends QC {
339
381
  return super.prefetchQuery(cloneDeepUnref(options))
340
382
  }
341
383
 
384
+ // These one-shot imperative methods do not resolve top-level option getters.
385
+ // Resolve getters explicitly before calling, e.g. queryClient.infiniteQuery(options()).
386
+ infiniteQuery<
387
+ TQueryFnData = unknown,
388
+ TError = DefaultError,
389
+ TData = InfiniteData<TQueryFnData>,
390
+ TQueryKey extends QueryKey = QueryKey,
391
+ TPageParam = unknown,
392
+ >(
393
+ options: InfiniteQueryExecuteOptions<
394
+ TQueryFnData,
395
+ TError,
396
+ TData,
397
+ TQueryKey,
398
+ TPageParam
399
+ >,
400
+ ): Promise<
401
+ Array<TData> extends Array<InfiniteData<TQueryFnData>>
402
+ ? InfiniteData<TQueryFnData, TPageParam>
403
+ : TData
404
+ >
405
+ infiniteQuery<
406
+ TQueryFnData = unknown,
407
+ TError = DefaultError,
408
+ TData = InfiniteData<TQueryFnData>,
409
+ TQueryKey extends QueryKey = QueryKey,
410
+ TPageParam = unknown,
411
+ >(
412
+ options: MaybeRefDeep<
413
+ InfiniteQueryExecuteOptions<
414
+ TQueryFnData,
415
+ TError,
416
+ TData,
417
+ TQueryKey,
418
+ TPageParam
419
+ >
420
+ >,
421
+ ): Promise<
422
+ Array<TData> extends Array<InfiniteData<TQueryFnData>>
423
+ ? InfiniteData<TQueryFnData, TPageParam>
424
+ : TData
425
+ >
426
+ infiniteQuery<
427
+ TQueryFnData = unknown,
428
+ TError = DefaultError,
429
+ TData = InfiniteData<TQueryFnData>,
430
+ TQueryKey extends QueryKey = QueryKey,
431
+ TPageParam = unknown,
432
+ >(
433
+ options: MaybeRefDeep<
434
+ InfiniteQueryExecuteOptions<
435
+ TQueryFnData,
436
+ TError,
437
+ TData,
438
+ TQueryKey,
439
+ TPageParam
440
+ >
441
+ >,
442
+ ): Promise<
443
+ Array<TData> extends Array<InfiniteData<TQueryFnData>>
444
+ ? InfiniteData<TQueryFnData, TPageParam>
445
+ : TData
446
+ > {
447
+ return super.infiniteQuery(cloneDeepUnref(options))
448
+ }
449
+
450
+ /**
451
+ * @deprecated Use queryClient.infiniteQuery(options) instead. This method will be removed in the next major version.
452
+ */
342
453
  fetchInfiniteQuery<
343
454
  TQueryFnData = unknown,
344
455
  TError = DefaultError,
@@ -391,6 +502,9 @@ export class QueryClient extends QC {
391
502
  return super.fetchInfiniteQuery(cloneDeepUnref(options))
392
503
  }
393
504
 
505
+ /**
506
+ * @deprecated use void queryClient.infiniteQuery(options) instead. You can swallow errors with `.catch(noop)`. This method will be removed in the next major version.
507
+ */
394
508
  prefetchInfiniteQuery<
395
509
  TQueryFnData,
396
510
  TError = DefaultError,
@@ -1,11 +1,11 @@
1
1
  import type { DeepUnwrapRef, MaybeRefOrGetter, ShallowOption } from './types'
2
2
  import type {
3
- DataTag,
4
3
  DefaultError,
5
4
  InitialDataFunction,
6
5
  NonUndefinedGuard,
7
6
  QueryBooleanOption,
8
7
  QueryKey,
8
+ QueryKeyWithDataTag,
9
9
  QueryObserverOptions,
10
10
  } from '@tanstack/query-core'
11
11
 
@@ -65,6 +65,22 @@ export type DefinedInitialQueryOptions<
65
65
  | (() => NonUndefinedGuard<TQueryFnData>)
66
66
  }
67
67
 
68
+ export type UndefinedInitialQueryOptionsWithDataTag<
69
+ TQueryFnData = unknown,
70
+ TError = DefaultError,
71
+ TData = TQueryFnData,
72
+ TQueryKey extends QueryKey = QueryKey,
73
+ > = UndefinedInitialQueryOptions<TQueryFnData, TError, TData, TQueryKey> &
74
+ QueryKeyWithDataTag<TQueryKey, TQueryFnData, TError>
75
+
76
+ export type DefinedInitialQueryOptionsWithDataTag<
77
+ TQueryFnData = unknown,
78
+ TError = DefaultError,
79
+ TData = TQueryFnData,
80
+ TQueryKey extends QueryKey = QueryKey,
81
+ > = DefinedInitialQueryOptions<TQueryFnData, TError, TData, TQueryKey> &
82
+ QueryKeyWithDataTag<TQueryKey, TQueryFnData, TError>
83
+
68
84
  export function queryOptions<
69
85
  TQueryFnData = unknown,
70
86
  TError = DefaultError,
@@ -72,9 +88,7 @@ export function queryOptions<
72
88
  TQueryKey extends QueryKey = QueryKey,
73
89
  >(
74
90
  options: DefinedInitialQueryOptions<TQueryFnData, TError, TData, TQueryKey>,
75
- ): DefinedInitialQueryOptions<TQueryFnData, TError, TData, TQueryKey> & {
76
- queryKey: DataTag<TQueryKey, TQueryFnData, TError>
77
- }
91
+ ): DefinedInitialQueryOptionsWithDataTag<TQueryFnData, TError, TData, TQueryKey>
78
92
 
79
93
  export function queryOptions<
80
94
  TQueryFnData = unknown,
@@ -88,9 +102,12 @@ export function queryOptions<
88
102
  TData,
89
103
  TQueryKey
90
104
  >,
91
- ): () => DefinedInitialQueryOptions<TQueryFnData, TError, TData, TQueryKey> & {
92
- queryKey: DataTag<TQueryKey, TQueryFnData, TError>
93
- }
105
+ ): () => DefinedInitialQueryOptionsWithDataTag<
106
+ TQueryFnData,
107
+ TError,
108
+ TData,
109
+ TQueryKey
110
+ >
94
111
 
95
112
  export function queryOptions<
96
113
  TQueryFnData = unknown,
@@ -99,9 +116,12 @@ export function queryOptions<
99
116
  TQueryKey extends QueryKey = QueryKey,
100
117
  >(
101
118
  options: UndefinedInitialQueryOptions<TQueryFnData, TError, TData, TQueryKey>,
102
- ): UndefinedInitialQueryOptions<TQueryFnData, TError, TData, TQueryKey> & {
103
- queryKey: DataTag<TQueryKey, TQueryFnData, TError>
104
- }
119
+ ): UndefinedInitialQueryOptionsWithDataTag<
120
+ TQueryFnData,
121
+ TError,
122
+ TData,
123
+ TQueryKey
124
+ >
105
125
 
106
126
  export function queryOptions<
107
127
  TQueryFnData = unknown,
@@ -115,14 +135,12 @@ export function queryOptions<
115
135
  TData,
116
136
  TQueryKey
117
137
  >,
118
- ): () => UndefinedInitialQueryOptions<
138
+ ): () => UndefinedInitialQueryOptionsWithDataTag<
119
139
  TQueryFnData,
120
140
  TError,
121
141
  TData,
122
142
  TQueryKey
123
- > & {
124
- queryKey: DataTag<TQueryKey, TQueryFnData, TError>
125
- }
143
+ >
126
144
 
127
145
  export function queryOptions(options: unknown) {
128
146
  return options
@@ -17,7 +17,6 @@ import type {
17
17
  DefaultError,
18
18
  DistributiveOmit,
19
19
  MutateFunction,
20
- MutateOptions,
21
20
  MutationObserverResult,
22
21
  } from '@tanstack/query-core'
23
22
  import type { MaybeRefDeep, MutationOptions } from './types'
@@ -108,10 +107,11 @@ export function useMutation<
108
107
  })
109
108
 
110
109
  const mutate = (
111
- variables: TVariables,
112
- mutateOptions?: MutateOptions<TData, TError, TVariables, TOnMutateResult>,
110
+ ...args: Parameters<
111
+ MutateFunction<TData, TError, TVariables, TOnMutateResult>
112
+ >
113
113
  ) => {
114
- observer.mutate(variables, mutateOptions).catch(() => {
114
+ observer.mutate(args[0] as TVariables, args[1]).catch(() => {
115
115
  // This is intentional
116
116
  })
117
117
  }