@tanstack/vue-query 5.103.1 → 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.
- package/build/legacy/devtools/devtools.d.cts +1 -1
- package/build/legacy/devtools/devtools.d.ts +1 -1
- package/build/legacy/devtools/utils.d.cts.map +1 -1
- package/build/legacy/devtools/utils.d.ts.map +1 -1
- package/build/legacy/index.d.cts +3 -3
- package/build/legacy/index.d.ts +3 -3
- package/build/legacy/{infiniteQueryOptions-qN6sOJM-.d.cts → infiniteQueryOptions-CnTRbIP5.d.cts} +16 -6
- package/build/legacy/infiniteQueryOptions-CnTRbIP5.d.cts.map +1 -0
- package/build/legacy/{infiniteQueryOptions-CEDiLwh5.d.ts → infiniteQueryOptions-NucMX_M_.d.ts} +16 -6
- package/build/legacy/infiniteQueryOptions-NucMX_M_.d.ts.map +1 -0
- package/build/legacy/infiniteQueryOptions.cjs.map +1 -1
- package/build/legacy/infiniteQueryOptions.d.cts +1 -1
- package/build/legacy/infiniteQueryOptions.d.ts +1 -1
- package/build/legacy/infiniteQueryOptions.js.map +1 -1
- package/build/legacy/mutationCache.d.cts.map +1 -1
- package/build/legacy/mutationCache.d.ts.map +1 -1
- package/build/legacy/mutationOptions.cjs.map +1 -1
- package/build/legacy/mutationOptions.d.cts +4 -0
- package/build/legacy/mutationOptions.d.cts.map +1 -1
- package/build/legacy/mutationOptions.d.ts +4 -0
- package/build/legacy/mutationOptions.d.ts.map +1 -1
- package/build/legacy/mutationOptions.js.map +1 -1
- package/build/legacy/queryCache.d.cts.map +1 -1
- package/build/legacy/queryCache.d.ts.map +1 -1
- package/build/legacy/{queryClient-Cv73nzNT.d.ts → queryClient-B6mLtXOj.d.ts} +9 -2
- package/build/legacy/queryClient-B6mLtXOj.d.ts.map +1 -0
- package/build/{modern/queryClient-CZeNAt68.d.cts → legacy/queryClient-Bn2Ql_Lu.d.cts} +9 -2
- package/build/legacy/queryClient-Bn2Ql_Lu.d.cts.map +1 -0
- package/build/legacy/queryClient.cjs +7 -0
- package/build/legacy/queryClient.cjs.map +1 -1
- package/build/legacy/queryClient.d.cts +1 -1
- package/build/legacy/queryClient.d.ts +1 -1
- package/build/legacy/queryClient.js +7 -0
- package/build/legacy/queryClient.js.map +1 -1
- package/build/{modern/queryOptions-DPDwdVBu.d.ts → legacy/queryOptions-CsM5TXD2.d.ts} +4 -3
- package/build/legacy/queryOptions-CsM5TXD2.d.ts.map +1 -0
- package/build/{modern/queryOptions-rkZ3sk6g.d.cts → legacy/queryOptions-CwqQgQmQ.d.cts} +4 -3
- package/build/legacy/queryOptions-CwqQgQmQ.d.cts.map +1 -0
- package/build/legacy/queryOptions.cjs.map +1 -1
- package/build/legacy/queryOptions.d.cts +1 -1
- package/build/legacy/queryOptions.d.ts +1 -1
- package/build/legacy/queryOptions.js.map +1 -1
- package/build/legacy/types-JpJB72CS.d.cts.map +1 -1
- package/build/legacy/types-JpJB72CS.d.ts.map +1 -1
- package/build/legacy/useBaseQuery.cjs.map +1 -1
- package/build/legacy/useBaseQuery.d.cts +1 -1
- package/build/legacy/useBaseQuery.d.ts +1 -1
- package/build/legacy/useBaseQuery.js.map +1 -1
- package/build/legacy/useInfiniteQuery.cjs.map +1 -1
- package/build/legacy/useInfiniteQuery.d.cts +1 -1
- package/build/legacy/useInfiniteQuery.d.ts +1 -1
- package/build/legacy/useInfiniteQuery.js.map +1 -1
- package/build/legacy/useIsFetching.cjs.map +1 -1
- package/build/legacy/useIsFetching.d.cts +1 -1
- package/build/legacy/useIsFetching.d.cts.map +1 -1
- package/build/legacy/useIsFetching.d.ts +1 -1
- package/build/legacy/useIsFetching.d.ts.map +1 -1
- package/build/legacy/useIsFetching.js.map +1 -1
- package/build/legacy/useMutation.d.cts +1 -1
- package/build/legacy/useMutation.d.cts.map +1 -1
- package/build/legacy/useMutation.d.ts +1 -1
- package/build/legacy/useMutation.d.ts.map +1 -1
- package/build/legacy/useMutationState.cjs.map +1 -1
- package/build/legacy/useMutationState.d.cts +1 -1
- package/build/legacy/useMutationState.d.cts.map +1 -1
- package/build/legacy/useMutationState.d.ts +1 -1
- package/build/legacy/useMutationState.d.ts.map +1 -1
- package/build/legacy/useMutationState.js.map +1 -1
- package/build/legacy/usePrefetchInfiniteQuery.d.cts +1 -1
- package/build/legacy/usePrefetchInfiniteQuery.d.cts.map +1 -1
- package/build/legacy/usePrefetchInfiniteQuery.d.ts +1 -1
- package/build/legacy/usePrefetchInfiniteQuery.d.ts.map +1 -1
- package/build/legacy/usePrefetchQuery.d.cts +1 -1
- package/build/legacy/usePrefetchQuery.d.cts.map +1 -1
- package/build/legacy/usePrefetchQuery.d.ts +1 -1
- package/build/legacy/usePrefetchQuery.d.ts.map +1 -1
- package/build/legacy/useQueries.d.cts +2 -2
- package/build/legacy/useQueries.d.cts.map +1 -1
- package/build/legacy/useQueries.d.ts +2 -2
- package/build/legacy/useQueries.d.ts.map +1 -1
- package/build/legacy/useQuery.cjs.map +1 -1
- package/build/legacy/useQuery.d.cts +13 -7
- package/build/legacy/useQuery.d.cts.map +1 -1
- package/build/legacy/useQuery.d.ts +13 -7
- package/build/legacy/useQuery.d.ts.map +1 -1
- package/build/legacy/useQuery.js.map +1 -1
- package/build/legacy/useQueryClient.d.cts +1 -1
- package/build/legacy/useQueryClient.d.ts +1 -1
- package/build/legacy/vueQueryPlugin.d.cts +1 -1
- package/build/legacy/vueQueryPlugin.d.ts +1 -1
- package/build/modern/devtools/devtools.d.cts +1 -1
- package/build/modern/devtools/devtools.d.ts +1 -1
- package/build/modern/devtools/utils.d.cts.map +1 -1
- package/build/modern/devtools/utils.d.ts.map +1 -1
- package/build/modern/index.d.cts +3 -3
- package/build/modern/index.d.ts +3 -3
- package/build/modern/{infiniteQueryOptions-qN6sOJM-.d.cts → infiniteQueryOptions-CnTRbIP5.d.cts} +16 -6
- package/build/modern/infiniteQueryOptions-CnTRbIP5.d.cts.map +1 -0
- package/build/modern/{infiniteQueryOptions-CEDiLwh5.d.ts → infiniteQueryOptions-NucMX_M_.d.ts} +16 -6
- package/build/modern/infiniteQueryOptions-NucMX_M_.d.ts.map +1 -0
- package/build/modern/infiniteQueryOptions.cjs.map +1 -1
- package/build/modern/infiniteQueryOptions.d.cts +1 -1
- package/build/modern/infiniteQueryOptions.d.ts +1 -1
- package/build/modern/infiniteQueryOptions.js.map +1 -1
- package/build/modern/mutationCache.d.cts.map +1 -1
- package/build/modern/mutationCache.d.ts.map +1 -1
- package/build/modern/mutationOptions.cjs.map +1 -1
- package/build/modern/mutationOptions.d.cts +4 -0
- package/build/modern/mutationOptions.d.cts.map +1 -1
- package/build/modern/mutationOptions.d.ts +4 -0
- package/build/modern/mutationOptions.d.ts.map +1 -1
- package/build/modern/mutationOptions.js.map +1 -1
- package/build/modern/queryCache.d.cts.map +1 -1
- package/build/modern/queryCache.d.ts.map +1 -1
- package/build/modern/{queryClient-Cv73nzNT.d.ts → queryClient-B6mLtXOj.d.ts} +9 -2
- package/build/modern/queryClient-B6mLtXOj.d.ts.map +1 -0
- package/build/{legacy/queryClient-CZeNAt68.d.cts → modern/queryClient-Bn2Ql_Lu.d.cts} +9 -2
- package/build/modern/queryClient-Bn2Ql_Lu.d.cts.map +1 -0
- package/build/modern/queryClient.cjs +7 -0
- package/build/modern/queryClient.cjs.map +1 -1
- package/build/modern/queryClient.d.cts +1 -1
- package/build/modern/queryClient.d.ts +1 -1
- package/build/modern/queryClient.js +7 -0
- package/build/modern/queryClient.js.map +1 -1
- package/build/{legacy/queryOptions-DPDwdVBu.d.ts → modern/queryOptions-CsM5TXD2.d.ts} +4 -3
- package/build/modern/queryOptions-CsM5TXD2.d.ts.map +1 -0
- package/build/{legacy/queryOptions-rkZ3sk6g.d.cts → modern/queryOptions-CwqQgQmQ.d.cts} +4 -3
- package/build/modern/queryOptions-CwqQgQmQ.d.cts.map +1 -0
- package/build/modern/queryOptions.cjs.map +1 -1
- package/build/modern/queryOptions.d.cts +1 -1
- package/build/modern/queryOptions.d.ts +1 -1
- package/build/modern/queryOptions.js.map +1 -1
- package/build/modern/types-JpJB72CS.d.cts.map +1 -1
- package/build/modern/types-JpJB72CS.d.ts.map +1 -1
- package/build/modern/useBaseQuery.cjs.map +1 -1
- package/build/modern/useBaseQuery.d.cts +1 -1
- package/build/modern/useBaseQuery.d.ts +1 -1
- package/build/modern/useBaseQuery.js.map +1 -1
- package/build/modern/useInfiniteQuery.cjs.map +1 -1
- package/build/modern/useInfiniteQuery.d.cts +1 -1
- package/build/modern/useInfiniteQuery.d.ts +1 -1
- package/build/modern/useInfiniteQuery.js.map +1 -1
- package/build/modern/useIsFetching.cjs.map +1 -1
- package/build/modern/useIsFetching.d.cts +1 -1
- package/build/modern/useIsFetching.d.cts.map +1 -1
- package/build/modern/useIsFetching.d.ts +1 -1
- package/build/modern/useIsFetching.d.ts.map +1 -1
- package/build/modern/useIsFetching.js.map +1 -1
- package/build/modern/useMutation.d.cts +1 -1
- package/build/modern/useMutation.d.cts.map +1 -1
- package/build/modern/useMutation.d.ts +1 -1
- package/build/modern/useMutation.d.ts.map +1 -1
- package/build/modern/useMutationState.cjs.map +1 -1
- package/build/modern/useMutationState.d.cts +1 -1
- package/build/modern/useMutationState.d.cts.map +1 -1
- package/build/modern/useMutationState.d.ts +1 -1
- package/build/modern/useMutationState.d.ts.map +1 -1
- package/build/modern/useMutationState.js.map +1 -1
- package/build/modern/usePrefetchInfiniteQuery.d.cts +1 -1
- package/build/modern/usePrefetchInfiniteQuery.d.cts.map +1 -1
- package/build/modern/usePrefetchInfiniteQuery.d.ts +1 -1
- package/build/modern/usePrefetchInfiniteQuery.d.ts.map +1 -1
- package/build/modern/usePrefetchQuery.d.cts +1 -1
- package/build/modern/usePrefetchQuery.d.cts.map +1 -1
- package/build/modern/usePrefetchQuery.d.ts +1 -1
- package/build/modern/usePrefetchQuery.d.ts.map +1 -1
- package/build/modern/useQueries.d.cts +2 -2
- package/build/modern/useQueries.d.cts.map +1 -1
- package/build/modern/useQueries.d.ts +2 -2
- package/build/modern/useQueries.d.ts.map +1 -1
- package/build/modern/useQuery.cjs.map +1 -1
- package/build/modern/useQuery.d.cts +13 -7
- package/build/modern/useQuery.d.cts.map +1 -1
- package/build/modern/useQuery.d.ts +13 -7
- package/build/modern/useQuery.d.ts.map +1 -1
- package/build/modern/useQuery.js.map +1 -1
- package/build/modern/useQueryClient.d.cts +1 -1
- package/build/modern/useQueryClient.d.ts +1 -1
- package/build/modern/vueQueryPlugin.d.cts +1 -1
- package/build/modern/vueQueryPlugin.d.ts +1 -1
- package/package.json +8 -8
- package/src/infiniteQueryOptions.ts +3 -2
- package/src/mutationOptions.ts +4 -0
- package/src/queryClient.ts +7 -0
- package/src/queryOptions.ts +29 -26
- package/src/useBaseQuery.ts +9 -3
- package/src/useInfiniteQuery.ts +11 -8
- package/src/useIsFetching.ts +1 -2
- package/src/useMutationState.ts +1 -2
- package/src/useQuery.ts +11 -6
- package/build/legacy/infiniteQueryOptions-CEDiLwh5.d.ts.map +0 -1
- package/build/legacy/infiniteQueryOptions-qN6sOJM-.d.cts.map +0 -1
- package/build/legacy/queryClient-CZeNAt68.d.cts.map +0 -1
- package/build/legacy/queryClient-Cv73nzNT.d.ts.map +0 -1
- package/build/legacy/queryOptions-DPDwdVBu.d.ts.map +0 -1
- package/build/legacy/queryOptions-rkZ3sk6g.d.cts.map +0 -1
- package/build/modern/infiniteQueryOptions-CEDiLwh5.d.ts.map +0 -1
- package/build/modern/infiniteQueryOptions-qN6sOJM-.d.cts.map +0 -1
- package/build/modern/queryClient-CZeNAt68.d.cts.map +0 -1
- package/build/modern/queryClient-Cv73nzNT.d.ts.map +0 -1
- package/build/modern/queryOptions-DPDwdVBu.d.ts.map +0 -1
- package/build/modern/queryOptions-rkZ3sk6g.d.cts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMutationState.cjs","names":["getCurrentScope","useQueryClient","computed","cloneDeepUnref","shallowRef","shallowReadonly"],"sources":["../../src/useMutationState.ts"],"sourcesContent":["import {\n computed,\n getCurrentScope,\n onScopeDispose,\n shallowReadonly,\n shallowRef,\n watch,\n} from 'vue-demi'\nimport { useQueryClient } from './useQueryClient'\nimport { cloneDeepUnref } from './utils'\nimport type { Ref } from 'vue-demi'\nimport type {\n Mutation,\n MutationFilters,\n MutationState,\n} from '@tanstack/query-core'\nimport type { QueryClient } from './queryClient'\nimport type { MaybeRefDeep } from './types'\nimport type { MutationCache } from './mutationCache'\n\ntype VueMutationFilters = MaybeRefDeep<MutationFilters>\n\nexport type UseIsMutatingFilters =\n
|
|
1
|
+
{"version":3,"file":"useMutationState.cjs","names":["getCurrentScope","useQueryClient","computed","cloneDeepUnref","shallowRef","shallowReadonly"],"sources":["../../src/useMutationState.ts"],"sourcesContent":["import {\n computed,\n getCurrentScope,\n onScopeDispose,\n shallowReadonly,\n shallowRef,\n watch,\n} from 'vue-demi'\nimport { useQueryClient } from './useQueryClient'\nimport { cloneDeepUnref } from './utils'\nimport type { Ref } from 'vue-demi'\nimport type {\n Mutation,\n MutationFilters,\n MutationState,\n} from '@tanstack/query-core'\nimport type { QueryClient } from './queryClient'\nimport type { MaybeRefDeep } from './types'\nimport type { MutationCache } from './mutationCache'\n\ntype VueMutationFilters = MaybeRefDeep<MutationFilters>\n\nexport type UseIsMutatingFilters =\n VueMutationFilters | (() => VueMutationFilters)\n\n/**\n * The `useIsMutating` composable returns a `ref` to the `number` of mutations that your application currently\n * has `pending` (useful for app-wide loading indicators).\n *\n * `filters` may be a plain object, `MaybeRefDeep`, or a reactive getter (`() => ({ ... })`) — pass a getter if\n * the filters themselves depend on other reactive state.\n *\n * @param filters - The {@link MutationFilters} to narrow down the matched mutations.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`\n * will be used.\n * @returns A `ref` to the `number` of the mutations that your application currently has `pending`.\n *\n * @example\n * ```vue\n * <script setup lang=\"ts\">\n * import { useIsMutating } from '@tanstack/vue-query'\n *\n * // How many mutations matching the posts prefix are in progress?\n * const isMutatingPosts = useIsMutating({ mutationKey: ['posts'] })\n * </script>\n *\n * <template>\n * <span v-if=\"isMutatingPosts\">Saving posts...</span>\n * </template>\n * ```\n */\nexport function useIsMutating(\n filters: UseIsMutatingFilters = {},\n queryClient?: QueryClient,\n): Ref<number> {\n if (process.env.NODE_ENV === 'development') {\n if (!getCurrentScope()) {\n console.warn(\n 'vue-query composable like \"useQuery()\" should only be used inside a \"setup()\" function or a running effect scope. They might otherwise lead to memory leaks.',\n )\n }\n }\n\n const client = queryClient || useQueryClient()\n\n const mutationState = useMutationState(\n {\n filters: computed(() => ({\n ...cloneDeepUnref(typeof filters === 'function' ? filters() : filters),\n status: 'pending' as const,\n })),\n },\n client,\n )\n const length = computed(() => mutationState.value.length)\n\n return length\n}\n\ntype MutationTypeFromResult<TResult> = [TResult] extends [\n MutationState<\n infer TData,\n infer TError,\n infer TVariables,\n infer TOnMutateResult\n >,\n]\n ? Mutation<TData, TError, TVariables, TOnMutateResult>\n : Mutation\n\nexport type MutationStateOptions<\n TResult = MutationState,\n TMutation extends Mutation<any, any, any, any> =\n MutationTypeFromResult<TResult>,\n> = {\n filters?: VueMutationFilters\n select?: (mutation: TMutation) => TResult\n}\n\nfunction getResult<\n TResult = MutationState,\n TMutation extends Mutation<any, any, any, any> =\n MutationTypeFromResult<TResult>,\n>(\n mutationCache: MutationCache,\n options: MutationStateOptions<TResult, TMutation>,\n): Array<TResult> {\n return mutationCache\n .findAll(options.filters)\n .map(\n (mutation): TResult =>\n (options.select\n ? options.select(mutation as TMutation)\n : mutation.state) as TResult,\n )\n}\n\n/**\n * `useMutationState` is a composable that gives you access to all mutations in the `MutationCache`. You can\n * pass `filters` ({@link MutationFilters}) to narrow down your mutations, and `select` to transform the\n * mutation state.\n *\n * `options` may be a plain object or a reactive getter (`() => ({ ... })`) — pass a getter if the filters\n * themselves depend on other reactive state.\n *\n * @param options - The `filters` to narrow down matched mutations, and an optional `select` to transform the\n * mutation state.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`\n * will be used.\n * @returns A `ref` to an Array of whatever `select` returns for each matching mutation.\n *\n * @example\n * Get all variables of all running mutations:\n * ```vue\n * <script setup lang=\"ts\">\n * import { useMutationState } from '@tanstack/vue-query'\n *\n * const pendingVariables = useMutationState({\n * filters: { status: 'pending' },\n * select: (mutation) => mutation.state.variables,\n * })\n * </script>\n *\n * <template>{{ pendingVariables.length }} posts saving...</template>\n * ```\n *\n * @example\n * Get all data for specific mutations via the `mutationKey`:\n * ```vue\n * <script setup lang=\"ts\">\n * import { useMutation, useMutationState } from '@tanstack/vue-query'\n *\n * const mutationKey = ['posts']\n *\n * // Some mutation that we want to get the state for\n * const mutation = useMutation({\n * mutationKey,\n * mutationFn: createPosts,\n * })\n *\n * const savedPosts = useMutationState({\n * // this mutation key needs to match the mutation key of the given mutation (see above)\n * filters: { mutationKey, status: 'success' },\n * select: (mutation) => mutation.state.data,\n * })\n * </script>\n *\n * <template>\n * <button @click=\"mutation.mutate(['New Post'])\">\n * Create post ({{ savedPosts.length }} saved so far)\n * </button>\n * </template>\n * ```\n *\n * @example\n * Access the latest successful mutation data via the `mutationKey`. Each invocation of `mutate` adds a new\n * entry to the mutation cache for `gcTime` milliseconds — with the `status: 'success'` filter below, check the\n * last item that `useMutationState` returns to get the latest successful invocation:\n * ```vue\n * <script setup lang=\"ts\">\n * import { computed } from 'vue'\n * import { useMutationState } from '@tanstack/vue-query'\n *\n * const savedPosts = useMutationState({\n * filters: { mutationKey: ['posts'], status: 'success' },\n * select: (mutation) => mutation.state.data,\n * })\n *\n * const latestSavedPost = computed(() => savedPosts.value[savedPosts.value.length - 1])\n * </script>\n *\n * <template>{{ latestSavedPost ? 'Saved' : 'Nothing saved yet' }}</template>\n * ```\n */\nexport function useMutationState<\n TResult = MutationState,\n TMutation extends Mutation<any, any, any, any> =\n MutationTypeFromResult<TResult>,\n>(\n options:\n | MutationStateOptions<TResult, TMutation>\n | (() => MutationStateOptions<TResult, TMutation>) = {},\n queryClient?: QueryClient,\n): Readonly<Ref<Array<TResult>>> {\n const resolvedOptions = computed(() => {\n const newOptions = typeof options === 'function' ? options() : options\n return {\n filters: cloneDeepUnref(newOptions.filters),\n select: newOptions.select,\n }\n })\n const mutationCache = (queryClient || useQueryClient()).getMutationCache()\n const state = shallowRef(getResult(mutationCache, resolvedOptions.value))\n const unsubscribe = mutationCache.subscribe(() => {\n state.value = getResult(mutationCache, resolvedOptions.value)\n })\n\n watch(resolvedOptions, () => {\n state.value = getResult(mutationCache, resolvedOptions.value)\n })\n\n onScopeDispose(() => {\n unsubscribe()\n })\n\n return shallowReadonly(state)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmDA,SAAgB,cACd,UAAgC,CAAC,GACjC,aACa;CACb,IAAI,QAAQ,IAAI,aAAa,eACvB;MAAA,EAAA,GAACA,SAAAA,gBAAAA,CAAgB,GACnB,QAAQ,KACN,kKACF;CAAA;CAIJ,MAAM,SAAS,eAAeC,uBAAAA,eAAe;CAE7C,MAAM,gBAAgB,iBACpB,EACE,UAAA,GAASC,SAAAA,SAAAA,QAAgB;EACvB,GAAGC,cAAAA,eAAe,OAAO,YAAY,aAAa,QAAQ,IAAI,OAAO;EACrE,QAAQ;CACV,EAAE,EACJ,GACA,MACF;CAGA,QAAA,GAFeD,SAAAA,SAAAA,OAAe,cAAc,MAAM,MAEtC;AACd;AAsBA,SAAS,UAKP,eACA,SACgB;CAChB,OAAO,cACJ,QAAQ,QAAQ,OAAO,CAAC,CACxB,KACE,aACE,QAAQ,SACL,QAAQ,OAAO,QAAqB,IACpC,SAAS,KACjB;AACJ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+EA,SAAgB,iBAKd,UAEuD,CAAC,GACxD,aAC+B;CAC/B,MAAM,mBAAA,GAAkBA,SAAAA,SAAAA,OAAe;EACrC,MAAM,aAAa,OAAO,YAAY,aAAa,QAAQ,IAAI;EAC/D,OAAO;GACL,SAASC,cAAAA,eAAe,WAAW,OAAO;GAC1C,QAAQ,WAAW;EACrB;CACF,CAAC;CACD,MAAM,iBAAiB,eAAeF,uBAAAA,eAAe,EAAA,CAAG,iBAAiB;CACzE,MAAM,SAAA,GAAQG,SAAAA,WAAAA,CAAW,UAAU,eAAe,gBAAgB,KAAK,CAAC;CACxE,MAAM,cAAc,cAAc,gBAAgB;EAChD,MAAM,QAAQ,UAAU,eAAe,gBAAgB,KAAK;CAC9D,CAAC;CAED,CAAA,GAAA,SAAA,MAAA,CAAM,uBAAuB;EAC3B,MAAM,QAAQ,UAAU,eAAe,gBAAgB,KAAK;CAC9D,CAAC;CAED,CAAA,GAAA,SAAA,eAAA,OAAqB;EACnB,YAAY;CACd,CAAC;CAED,QAAA,GAAOC,SAAAA,gBAAAA,CAAgB,KAAK;AAC9B"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { o as MaybeRefDeep } from "./types-JpJB72CS.cjs";
|
|
2
|
-
import { t as QueryClient$1 } from "./queryClient-
|
|
2
|
+
import { t as QueryClient$1 } from "./queryClient-Bn2Ql_Lu.cjs";
|
|
3
3
|
import { Mutation, MutationFilters, MutationState } from "@tanstack/query-core";
|
|
4
4
|
import { Ref } from "vue-demi";
|
|
5
5
|
//#region src/useMutationState.d.ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMutationState.d.cts","names":[],"sources":["../../src/useMutationState.ts"],"mappings":";;;;;KAoBK,qBAAqB,aAAa;KAE3B,
|
|
1
|
+
{"version":3,"file":"useMutationState.d.cts","names":["QueryClient"],"sources":["../../src/useMutationState.ts"],"mappings":";;;;;KAoBK,qBAAqB,aAAa;KAE3B,uBACV,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA4Bd,cACd,UAAS,sBACT,cAAcA,gBACb;KAyBE,uBAAuB,YAAY,kBACtC,oBACQ,aACA,cACA,kBACA,oBAGN,SAAS,OAAO,QAAQ,YAAY,mBACpC;KAEQ,qBACV,UAAU,eACV,kBAAkB,+BAChB,uBAAuB;EAEzB,UAAU;EACV,UAAU,UAAU,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAkGpB,iBACd,UAAU,eACV,kBAAkB,+BAChB,uBAAuB,UAEzB,UACI,qBAAqB,SAAS,oBACvB,qBAAqB,SAAS,aACzC,cAAcA,gBACb,SAAS,IAAI,MAAM"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { o as MaybeRefDeep } from "./types-JpJB72CS.js";
|
|
2
|
-
import { t as QueryClient$1 } from "./queryClient-
|
|
2
|
+
import { t as QueryClient$1 } from "./queryClient-B6mLtXOj.js";
|
|
3
3
|
import { Mutation, MutationFilters, MutationState } from "@tanstack/query-core";
|
|
4
4
|
import { Ref } from "vue-demi";
|
|
5
5
|
//#region src/useMutationState.d.ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMutationState.d.ts","names":[],"sources":["../../src/useMutationState.ts"],"mappings":";;;;;KAoBK,qBAAqB,aAAa;KAE3B,
|
|
1
|
+
{"version":3,"file":"useMutationState.d.ts","names":["QueryClient"],"sources":["../../src/useMutationState.ts"],"mappings":";;;;;KAoBK,qBAAqB,aAAa;KAE3B,uBACV,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA4Bd,cACd,UAAS,sBACT,cAAcA,gBACb;KAyBE,uBAAuB,YAAY,kBACtC,oBACQ,aACA,cACA,kBACA,oBAGN,SAAS,OAAO,QAAQ,YAAY,mBACpC;KAEQ,qBACV,UAAU,eACV,kBAAkB,+BAChB,uBAAuB;EAEzB,UAAU;EACV,UAAU,UAAU,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAkGpB,iBACd,UAAU,eACV,kBAAkB,+BAChB,uBAAuB,UAEzB,UACI,qBAAqB,SAAS,oBACvB,qBAAqB,SAAS,aACzC,cAAcA,gBACb,SAAS,IAAI,MAAM"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMutationState.js","names":[],"sources":["../../src/useMutationState.ts"],"sourcesContent":["import {\n computed,\n getCurrentScope,\n onScopeDispose,\n shallowReadonly,\n shallowRef,\n watch,\n} from 'vue-demi'\nimport { useQueryClient } from './useQueryClient'\nimport { cloneDeepUnref } from './utils'\nimport type { Ref } from 'vue-demi'\nimport type {\n Mutation,\n MutationFilters,\n MutationState,\n} from '@tanstack/query-core'\nimport type { QueryClient } from './queryClient'\nimport type { MaybeRefDeep } from './types'\nimport type { MutationCache } from './mutationCache'\n\ntype VueMutationFilters = MaybeRefDeep<MutationFilters>\n\nexport type UseIsMutatingFilters =\n
|
|
1
|
+
{"version":3,"file":"useMutationState.js","names":[],"sources":["../../src/useMutationState.ts"],"sourcesContent":["import {\n computed,\n getCurrentScope,\n onScopeDispose,\n shallowReadonly,\n shallowRef,\n watch,\n} from 'vue-demi'\nimport { useQueryClient } from './useQueryClient'\nimport { cloneDeepUnref } from './utils'\nimport type { Ref } from 'vue-demi'\nimport type {\n Mutation,\n MutationFilters,\n MutationState,\n} from '@tanstack/query-core'\nimport type { QueryClient } from './queryClient'\nimport type { MaybeRefDeep } from './types'\nimport type { MutationCache } from './mutationCache'\n\ntype VueMutationFilters = MaybeRefDeep<MutationFilters>\n\nexport type UseIsMutatingFilters =\n VueMutationFilters | (() => VueMutationFilters)\n\n/**\n * The `useIsMutating` composable returns a `ref` to the `number` of mutations that your application currently\n * has `pending` (useful for app-wide loading indicators).\n *\n * `filters` may be a plain object, `MaybeRefDeep`, or a reactive getter (`() => ({ ... })`) — pass a getter if\n * the filters themselves depend on other reactive state.\n *\n * @param filters - The {@link MutationFilters} to narrow down the matched mutations.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`\n * will be used.\n * @returns A `ref` to the `number` of the mutations that your application currently has `pending`.\n *\n * @example\n * ```vue\n * <script setup lang=\"ts\">\n * import { useIsMutating } from '@tanstack/vue-query'\n *\n * // How many mutations matching the posts prefix are in progress?\n * const isMutatingPosts = useIsMutating({ mutationKey: ['posts'] })\n * </script>\n *\n * <template>\n * <span v-if=\"isMutatingPosts\">Saving posts...</span>\n * </template>\n * ```\n */\nexport function useIsMutating(\n filters: UseIsMutatingFilters = {},\n queryClient?: QueryClient,\n): Ref<number> {\n if (process.env.NODE_ENV === 'development') {\n if (!getCurrentScope()) {\n console.warn(\n 'vue-query composable like \"useQuery()\" should only be used inside a \"setup()\" function or a running effect scope. They might otherwise lead to memory leaks.',\n )\n }\n }\n\n const client = queryClient || useQueryClient()\n\n const mutationState = useMutationState(\n {\n filters: computed(() => ({\n ...cloneDeepUnref(typeof filters === 'function' ? filters() : filters),\n status: 'pending' as const,\n })),\n },\n client,\n )\n const length = computed(() => mutationState.value.length)\n\n return length\n}\n\ntype MutationTypeFromResult<TResult> = [TResult] extends [\n MutationState<\n infer TData,\n infer TError,\n infer TVariables,\n infer TOnMutateResult\n >,\n]\n ? Mutation<TData, TError, TVariables, TOnMutateResult>\n : Mutation\n\nexport type MutationStateOptions<\n TResult = MutationState,\n TMutation extends Mutation<any, any, any, any> =\n MutationTypeFromResult<TResult>,\n> = {\n filters?: VueMutationFilters\n select?: (mutation: TMutation) => TResult\n}\n\nfunction getResult<\n TResult = MutationState,\n TMutation extends Mutation<any, any, any, any> =\n MutationTypeFromResult<TResult>,\n>(\n mutationCache: MutationCache,\n options: MutationStateOptions<TResult, TMutation>,\n): Array<TResult> {\n return mutationCache\n .findAll(options.filters)\n .map(\n (mutation): TResult =>\n (options.select\n ? options.select(mutation as TMutation)\n : mutation.state) as TResult,\n )\n}\n\n/**\n * `useMutationState` is a composable that gives you access to all mutations in the `MutationCache`. You can\n * pass `filters` ({@link MutationFilters}) to narrow down your mutations, and `select` to transform the\n * mutation state.\n *\n * `options` may be a plain object or a reactive getter (`() => ({ ... })`) — pass a getter if the filters\n * themselves depend on other reactive state.\n *\n * @param options - The `filters` to narrow down matched mutations, and an optional `select` to transform the\n * mutation state.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`\n * will be used.\n * @returns A `ref` to an Array of whatever `select` returns for each matching mutation.\n *\n * @example\n * Get all variables of all running mutations:\n * ```vue\n * <script setup lang=\"ts\">\n * import { useMutationState } from '@tanstack/vue-query'\n *\n * const pendingVariables = useMutationState({\n * filters: { status: 'pending' },\n * select: (mutation) => mutation.state.variables,\n * })\n * </script>\n *\n * <template>{{ pendingVariables.length }} posts saving...</template>\n * ```\n *\n * @example\n * Get all data for specific mutations via the `mutationKey`:\n * ```vue\n * <script setup lang=\"ts\">\n * import { useMutation, useMutationState } from '@tanstack/vue-query'\n *\n * const mutationKey = ['posts']\n *\n * // Some mutation that we want to get the state for\n * const mutation = useMutation({\n * mutationKey,\n * mutationFn: createPosts,\n * })\n *\n * const savedPosts = useMutationState({\n * // this mutation key needs to match the mutation key of the given mutation (see above)\n * filters: { mutationKey, status: 'success' },\n * select: (mutation) => mutation.state.data,\n * })\n * </script>\n *\n * <template>\n * <button @click=\"mutation.mutate(['New Post'])\">\n * Create post ({{ savedPosts.length }} saved so far)\n * </button>\n * </template>\n * ```\n *\n * @example\n * Access the latest successful mutation data via the `mutationKey`. Each invocation of `mutate` adds a new\n * entry to the mutation cache for `gcTime` milliseconds — with the `status: 'success'` filter below, check the\n * last item that `useMutationState` returns to get the latest successful invocation:\n * ```vue\n * <script setup lang=\"ts\">\n * import { computed } from 'vue'\n * import { useMutationState } from '@tanstack/vue-query'\n *\n * const savedPosts = useMutationState({\n * filters: { mutationKey: ['posts'], status: 'success' },\n * select: (mutation) => mutation.state.data,\n * })\n *\n * const latestSavedPost = computed(() => savedPosts.value[savedPosts.value.length - 1])\n * </script>\n *\n * <template>{{ latestSavedPost ? 'Saved' : 'Nothing saved yet' }}</template>\n * ```\n */\nexport function useMutationState<\n TResult = MutationState,\n TMutation extends Mutation<any, any, any, any> =\n MutationTypeFromResult<TResult>,\n>(\n options:\n | MutationStateOptions<TResult, TMutation>\n | (() => MutationStateOptions<TResult, TMutation>) = {},\n queryClient?: QueryClient,\n): Readonly<Ref<Array<TResult>>> {\n const resolvedOptions = computed(() => {\n const newOptions = typeof options === 'function' ? options() : options\n return {\n filters: cloneDeepUnref(newOptions.filters),\n select: newOptions.select,\n }\n })\n const mutationCache = (queryClient || useQueryClient()).getMutationCache()\n const state = shallowRef(getResult(mutationCache, resolvedOptions.value))\n const unsubscribe = mutationCache.subscribe(() => {\n state.value = getResult(mutationCache, resolvedOptions.value)\n })\n\n watch(resolvedOptions, () => {\n state.value = getResult(mutationCache, resolvedOptions.value)\n })\n\n onScopeDispose(() => {\n unsubscribe()\n })\n\n return shallowReadonly(state)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmDA,SAAgB,cACd,UAAgC,CAAC,GACjC,aACa;CACb,IAAI,QAAQ,IAAI,aAAa,eACvB;MAAA,CAAC,gBAAgB,GACnB,QAAQ,KACN,kKACF;CAAA;CAIJ,MAAM,SAAS,eAAe,eAAe;CAE7C,MAAM,gBAAgB,iBACpB,EACE,SAAS,gBAAgB;EACvB,GAAG,eAAe,OAAO,YAAY,aAAa,QAAQ,IAAI,OAAO;EACrE,QAAQ;CACV,EAAE,EACJ,GACA,MACF;CAGA,OAFe,eAAe,cAAc,MAAM,MAEtC;AACd;AAsBA,SAAS,UAKP,eACA,SACgB;CAChB,OAAO,cACJ,QAAQ,QAAQ,OAAO,CAAC,CACxB,KACE,aACE,QAAQ,SACL,QAAQ,OAAO,QAAqB,IACpC,SAAS,KACjB;AACJ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+EA,SAAgB,iBAKd,UAEuD,CAAC,GACxD,aAC+B;CAC/B,MAAM,kBAAkB,eAAe;EACrC,MAAM,aAAa,OAAO,YAAY,aAAa,QAAQ,IAAI;EAC/D,OAAO;GACL,SAAS,eAAe,WAAW,OAAO;GAC1C,QAAQ,WAAW;EACrB;CACF,CAAC;CACD,MAAM,iBAAiB,eAAe,eAAe,EAAA,CAAG,iBAAiB;CACzE,MAAM,QAAQ,WAAW,UAAU,eAAe,gBAAgB,KAAK,CAAC;CACxE,MAAM,cAAc,cAAc,gBAAgB;EAChD,MAAM,QAAQ,UAAU,eAAe,gBAAgB,KAAK;CAC9D,CAAC;CAED,MAAM,uBAAuB;EAC3B,MAAM,QAAQ,UAAU,eAAe,gBAAgB,KAAK;CAC9D,CAAC;CAED,qBAAqB;EACnB,YAAY;CACd,CAAC;CAED,OAAO,gBAAgB,KAAK;AAC9B"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { o as MaybeRefDeep, s as MaybeRefOrGetter } from "./types-JpJB72CS.cjs";
|
|
2
|
-
import { t as QueryClient$1 } from "./queryClient-
|
|
2
|
+
import { t as QueryClient$1 } from "./queryClient-Bn2Ql_Lu.cjs";
|
|
3
3
|
import { DefaultError, DistributiveOmit, InfiniteData, InfiniteQueryExecuteOptions, QueryKey, SkipToken } from "@tanstack/query-core";
|
|
4
4
|
//#region src/usePrefetchInfiniteQuery.d.ts
|
|
5
5
|
type UsePrefetchInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey extends QueryKey, TPageParam> = DistributiveOmit<InfiniteQueryExecuteOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>, 'queryFn'> & {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePrefetchInfiniteQuery.d.cts","names":[],"sources":["../../src/usePrefetchInfiniteQuery.ts"],"mappings":";;;;KAeY,gCACV,cACA,QACA,OACA,kBAAkB,UAClB,cACE,iBACF,4BACE,cACA,QACA,OACA,WACA;EAIF,UAAU,QACR,4BACE,cACA,QACA,OACA,WACA,wBAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAsDY,yBACd,wBACA,SAAS,cACT,QAAQ,aAAa,eACrB,kBAAkB,WAAW,UAC7B,sBAEA,SAAS,iBACP,aACE,gCACE,cACA,QACA,OACA,WACA,eAIN,
|
|
1
|
+
{"version":3,"file":"usePrefetchInfiniteQuery.d.cts","names":["QueryClient"],"sources":["../../src/usePrefetchInfiniteQuery.ts"],"mappings":";;;;KAeY,gCACV,cACA,QACA,OACA,kBAAkB,UAClB,cACE,iBACF,4BACE,cACA,QACA,OACA,WACA;EAIF,UAAU,QACR,4BACE,cACA,QACA,OACA,WACA,wBAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAsDY,yBACd,wBACA,SAAS,cACT,QAAQ,aAAa,eACrB,kBAAkB,WAAW,UAC7B,sBAEA,SAAS,iBACP,aACE,gCACE,cACA,QACA,OACA,WACA,eAIN,cAAcA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { o as MaybeRefDeep, s as MaybeRefOrGetter } from "./types-JpJB72CS.js";
|
|
2
|
-
import { t as QueryClient$1 } from "./queryClient-
|
|
2
|
+
import { t as QueryClient$1 } from "./queryClient-B6mLtXOj.js";
|
|
3
3
|
import { DefaultError, DistributiveOmit, InfiniteData, InfiniteQueryExecuteOptions, QueryKey, SkipToken } from "@tanstack/query-core";
|
|
4
4
|
//#region src/usePrefetchInfiniteQuery.d.ts
|
|
5
5
|
type UsePrefetchInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey extends QueryKey, TPageParam> = DistributiveOmit<InfiniteQueryExecuteOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>, 'queryFn'> & {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePrefetchInfiniteQuery.d.ts","names":[],"sources":["../../src/usePrefetchInfiniteQuery.ts"],"mappings":";;;;KAeY,gCACV,cACA,QACA,OACA,kBAAkB,UAClB,cACE,iBACF,4BACE,cACA,QACA,OACA,WACA;EAIF,UAAU,QACR,4BACE,cACA,QACA,OACA,WACA,wBAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAsDY,yBACd,wBACA,SAAS,cACT,QAAQ,aAAa,eACrB,kBAAkB,WAAW,UAC7B,sBAEA,SAAS,iBACP,aACE,gCACE,cACA,QACA,OACA,WACA,eAIN,
|
|
1
|
+
{"version":3,"file":"usePrefetchInfiniteQuery.d.ts","names":["QueryClient"],"sources":["../../src/usePrefetchInfiniteQuery.ts"],"mappings":";;;;KAeY,gCACV,cACA,QACA,OACA,kBAAkB,UAClB,cACE,iBACF,4BACE,cACA,QACA,OACA,WACA;EAIF,UAAU,QACR,4BACE,cACA,QACA,OACA,WACA,wBAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAsDY,yBACd,wBACA,SAAS,cACT,QAAQ,aAAa,eACrB,kBAAkB,WAAW,UAC7B,sBAEA,SAAS,iBACP,aACE,gCACE,cACA,QACA,OACA,WACA,eAIN,cAAcA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { o as MaybeRefDeep, s as MaybeRefOrGetter } from "./types-JpJB72CS.cjs";
|
|
2
|
-
import { t as QueryClient$1 } from "./queryClient-
|
|
2
|
+
import { t as QueryClient$1 } from "./queryClient-Bn2Ql_Lu.cjs";
|
|
3
3
|
import { DefaultError, OmitKeyof, QueryExecuteOptions, QueryKey, SkipToken } from "@tanstack/query-core";
|
|
4
4
|
//#region src/usePrefetchQuery.d.ts
|
|
5
5
|
type UsePrefetchQueryOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey extends QueryKey> = OmitKeyof<QueryExecuteOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey, never>, 'queryFn'> & {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePrefetchQuery.d.cts","names":[],"sources":["../../src/usePrefetchQuery.ts"],"mappings":";;;;KAcY,wBACV,cACA,QACA,OACA,YACA,kBAAkB,YAChB,UACF,oBACE,cACA,QACA,OACA,YACA;EAKF,UAAU,QACR,oBACE,cACA,QACA,OACA,YACA,8BAGF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA6CY,iBACd,wBACA,SAAS,cACT,QAAQ,cACR,aAAa,cACb,kBAAkB,WAAW,UAE7B,SAAS,iBACP,aACE,wBACE,cACA,QACA,OACA,YACA,cAIN,
|
|
1
|
+
{"version":3,"file":"usePrefetchQuery.d.cts","names":["QueryClient"],"sources":["../../src/usePrefetchQuery.ts"],"mappings":";;;;KAcY,wBACV,cACA,QACA,OACA,YACA,kBAAkB,YAChB,UACF,oBACE,cACA,QACA,OACA,YACA;EAKF,UAAU,QACR,oBACE,cACA,QACA,OACA,YACA,8BAGF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA6CY,iBACd,wBACA,SAAS,cACT,QAAQ,cACR,aAAa,cACb,kBAAkB,WAAW,UAE7B,SAAS,iBACP,aACE,wBACE,cACA,QACA,OACA,YACA,cAIN,cAAcA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { o as MaybeRefDeep, s as MaybeRefOrGetter } from "./types-JpJB72CS.js";
|
|
2
|
-
import { t as QueryClient$1 } from "./queryClient-
|
|
2
|
+
import { t as QueryClient$1 } from "./queryClient-B6mLtXOj.js";
|
|
3
3
|
import { DefaultError, OmitKeyof, QueryExecuteOptions, QueryKey, SkipToken } from "@tanstack/query-core";
|
|
4
4
|
//#region src/usePrefetchQuery.d.ts
|
|
5
5
|
type UsePrefetchQueryOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey extends QueryKey> = OmitKeyof<QueryExecuteOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey, never>, 'queryFn'> & {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePrefetchQuery.d.ts","names":[],"sources":["../../src/usePrefetchQuery.ts"],"mappings":";;;;KAcY,wBACV,cACA,QACA,OACA,YACA,kBAAkB,YAChB,UACF,oBACE,cACA,QACA,OACA,YACA;EAKF,UAAU,QACR,oBACE,cACA,QACA,OACA,YACA,8BAGF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA6CY,iBACd,wBACA,SAAS,cACT,QAAQ,cACR,aAAa,cACb,kBAAkB,WAAW,UAE7B,SAAS,iBACP,aACE,wBACE,cACA,QACA,OACA,YACA,cAIN,
|
|
1
|
+
{"version":3,"file":"usePrefetchQuery.d.ts","names":["QueryClient"],"sources":["../../src/usePrefetchQuery.ts"],"mappings":";;;;KAcY,wBACV,cACA,QACA,OACA,YACA,kBAAkB,YAChB,UACF,oBACE,cACA,QACA,OACA,YACA;EAKF,UAAU,QACR,oBACE,cACA,QACA,OACA,YACA,8BAGF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA6CY,iBACd,wBACA,SAAS,cACT,QAAQ,cACR,aAAa,cACb,kBAAkB,WAAW,UAE7B,SAAS,iBACP,aACE,wBACE,cACA,QACA,OACA,YACA,cAIN,cAAcA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { d as ShallowOption, o as MaybeRefDeep, t as DeepUnwrapRef } from "./types-JpJB72CS.cjs";
|
|
2
|
-
import { o as UseQueryOptions } from "./queryOptions-
|
|
3
|
-
import { t as QueryClient$1 } from "./queryClient-
|
|
2
|
+
import { o as UseQueryOptions } from "./queryOptions-CwqQgQmQ.cjs";
|
|
3
|
+
import { t as QueryClient$1 } from "./queryClient-Bn2Ql_Lu.cjs";
|
|
4
4
|
import { DefaultError, DefinedQueryObserverResult, QueryFunction, QueryKey, QueryObserverResult, ThrowOnError } from "@tanstack/query-core";
|
|
5
5
|
import { Ref } from "vue-demi";
|
|
6
6
|
//#region src/useQueries.d.ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useQueries.d.cts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C,aAAa,qBAAqB,MAClC,6BAEU,WAAW,IAAI,gCAAgC,EAAE;EAG/D,WAAW,QAAQ,kBAAkB,OAAO;GAE9C,cAAcA,gBACb,SAAS,IAAI"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { d as ShallowOption, o as MaybeRefDeep, t as DeepUnwrapRef } from "./types-JpJB72CS.js";
|
|
2
|
-
import { o as UseQueryOptions } from "./queryOptions-
|
|
3
|
-
import { t as QueryClient$1 } from "./queryClient-
|
|
2
|
+
import { o as UseQueryOptions } from "./queryOptions-CsM5TXD2.js";
|
|
3
|
+
import { t as QueryClient$1 } from "./queryClient-B6mLtXOj.js";
|
|
4
4
|
import { DefaultError, DefinedQueryObserverResult, QueryFunction, QueryKey, QueryObserverResult, ThrowOnError } from "@tanstack/query-core";
|
|
5
5
|
import { Ref } from "vue-demi";
|
|
6
6
|
//#region src/useQueries.d.ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useQueries.d.ts","names":[],"sources":["../../src/useQueries.ts"],"mappings":";;;;;;KA8BK,6BACH,wBACA,kBACA,QAAQ,cACR,kBAAkB,WAAW,YAC3B,gBAAgB,cAAc,QAAQ,OAAO,cAAc;KAG1D;KAGA;KAEA,gCAAgC,KAEnC,UAAU,kBACN,cAAc,KAEd;EACI,mBAAmB;EACnB,cAAc;EACd,YAAY;IAEd,6BAA6B,cAAc,QAAQ,SACnD;EAAY,mBAAmB;EAAc,cAAc;IACzD,6BAA6B,cAAc,UAC3C;EAAY,YAAY;EAAO,cAAc;IAC3C,sCAAsC,QAAQ,SAE9C,iBAAiB,oBAAoB,cAAc,SACjD,6BAA6B,cAAc,QAAQ,SACnD,iBAAiB,oBAAoB,UACnC,6BAA6B,cAAc,UAC3C,iBAAiB,gBACf,6BAA6B,gBAE7B;EACI,UACI,oBAAoB,oBAAoB,aACxC;EACJ,UAAU,oBAAoB;EAC9B,eAAe,wBAAwB;IAEzC,6BACE,8BACgB,SAAS,eAAe,wBACxB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YACA,UAAU,gCAAgC,YAC1C,cAEN,+BAA+B,IAC7B,IAGA,UAAU,MACN,mCACQ,oBACA,cACA,aACA,cAGV,MACE,6BACE,cACA,QACA,OACA,cAIJ,MAAM;;;;KAKR,kBACV,UAAU,YACV,iBAAiB,iBACjB,eAAe,8BACb,yBAAyB,gBACzB,MAAM,uBACN,oBAEE,iBAAiB,YACX,UAAU,kBAAkB,SAChC,iBAAiB,eAAe,SAC9B,sBACM,YACA,UAAU,kBAAkB,YAC5B,iBAEH,WAAW,IAAI,kBAAkB,EAAE;KAE3C,qBAAqB,UAAU,2BAC/B,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA8HP,WACd,UAAU,YACV,kBAAkB,kBAAkB,MAGlC,YACG,WACF;EACD,gBACW,aAAa,qBAAqB,OACzC,aAAa,qBAAqB,MAClC,6BAEU,WAAW,IAAI,gCAAgC,EAAE;EAG/D,WAAW,QAAQ,kBAAkB,OAAO;GAE9C,cAAcA,gBACb,SAAS,IAAI"}
|
|
@@ -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-
|
|
3
|
-
import { t as QueryClient$1 } from "./queryClient-
|
|
4
|
-
import { s as UseBaseQueryReturnType } from "./infiniteQueryOptions-
|
|
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` (`
|
|
22
|
-
* `pending` in this overload's type, since
|
|
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
|
|
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-
|
|
3
|
-
import { t as QueryClient$1 } from "./queryClient-
|
|
4
|
-
import { s as UseBaseQueryReturnType } from "./infiniteQueryOptions-
|
|
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` (`
|
|
22
|
-
* `pending` in this overload's type, since
|
|
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
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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 {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/vue-query",
|
|
3
|
-
"version": "5.103.
|
|
3
|
+
"version": "5.103.3",
|
|
4
4
|
"description": "Hooks for managing, caching and syncing asynchronous and remote data in Vue",
|
|
5
5
|
"author": "Damian Osipiuk",
|
|
6
6
|
"license": "MIT",
|
|
@@ -39,19 +39,19 @@
|
|
|
39
39
|
"!src/__tests__"
|
|
40
40
|
],
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@tanstack/match-sorter-utils": "^
|
|
42
|
+
"@tanstack/match-sorter-utils": "^9.1.2",
|
|
43
|
+
"@tanstack/query-core": "5.103.3",
|
|
43
44
|
"@vue/devtools-api": "^6.6.3",
|
|
44
|
-
"vue-demi": "^0.14.10"
|
|
45
|
-
"@tanstack/query-core": "5.103.1"
|
|
45
|
+
"vue-demi": "^0.14.10"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
+
"@tanstack/query-test-utils": "0.0.0",
|
|
48
49
|
"@vitejs/plugin-vue": "^5.2.4",
|
|
49
50
|
"@vue/composition-api": "1.7.2",
|
|
50
|
-
"eslint-plugin-vue": "^10.
|
|
51
|
-
"vue": "^3.
|
|
51
|
+
"eslint-plugin-vue": "^10.11.1",
|
|
52
|
+
"vue": "^3.5.43",
|
|
52
53
|
"vue2": "npm:vue@2.6",
|
|
53
|
-
"vue2.7": "npm:vue@2.7"
|
|
54
|
-
"@tanstack/query-test-utils": "0.0.0"
|
|
54
|
+
"vue2.7": "npm:vue@2.7"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
57
|
"@vue/composition-api": "^1.1.2",
|
|
@@ -36,7 +36,7 @@ export type UndefinedInitialDataInfiniteOptions<
|
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
38
|
* The options accepted by the `infiniteQueryOptions` overload selected when `initialData` is set — `data` is
|
|
39
|
-
* never `undefined
|
|
39
|
+
* never `undefined` (unless a `select` changes `TData` to include `undefined`).
|
|
40
40
|
*
|
|
41
41
|
* @template TQueryFnData - The type of a single page, as your `queryFn` resolves it.
|
|
42
42
|
* @template TError - The type of errors your `queryFn` may throw.
|
|
@@ -124,7 +124,8 @@ export function infiniteQueryOptions<
|
|
|
124
124
|
* These options can be shared across hooks and imperative APIs such as `queryClient.infiniteQuery`.
|
|
125
125
|
* `options.queryKey` is required and is the query key to generate options for.
|
|
126
126
|
*
|
|
127
|
-
* This overload is selected when `initialData` is set, so the resulting `data` is never `undefined
|
|
127
|
+
* This overload is selected when `initialData` is set, so the resulting `data` is never `undefined` (unless
|
|
128
|
+
* a `select` changes `TData` to include `undefined`).
|
|
128
129
|
*
|
|
129
130
|
* @see {@link useInfiniteQuery} to run an infinite query with these options.
|
|
130
131
|
* @param options - The {@link DefinedInitialDataInfiniteOptions} to use — everything you can pass to
|
package/src/mutationOptions.ts
CHANGED
|
@@ -6,6 +6,10 @@ import type { MutationOptions } from './types'
|
|
|
6
6
|
* `mutationKey` is required on this overload so the mutation can be looked up later, e.g. with
|
|
7
7
|
* `useMutationState`.
|
|
8
8
|
*
|
|
9
|
+
* Unlike a `queryKey` property on a query's options (e.g. `queryOptions({ queryKey: [...] })`), `mutationKey`
|
|
10
|
+
* entries that are reactive getters (`() => id.value`) are never unwrapped — the getter function itself is
|
|
11
|
+
* stored as the entry, rather than its current value. `ref` entries are still unwrapped normally.
|
|
12
|
+
*
|
|
9
13
|
* @see {@link useMutation} to run the mutation these options describe.
|
|
10
14
|
* @param options - The mutation options to use, identical to what you'd pass to `useMutation`, with a
|
|
11
15
|
* required `mutationKey`.
|
package/src/queryClient.ts
CHANGED
|
@@ -39,6 +39,13 @@ import type {
|
|
|
39
39
|
* `CancelOptions` or `InvalidateOptions`) or filters (such as the `QueryFilters` accepted by
|
|
40
40
|
* `invalidateQueries`) also accept a {@link MaybeRefDeep} version of it, so you can pass `ref`s directly
|
|
41
41
|
* without unwrapping them yourself — e.g. `queryClient.invalidateQueries({ queryKey: ['post', myRef] })`.
|
|
42
|
+
*
|
|
43
|
+
* `ref` entries in a `queryKey` are unwrapped this way on every method, but reactive getter entries
|
|
44
|
+
* (`() => id.value`) are only unwrapped when the `queryKey` is passed as a `queryKey` property of a
|
|
45
|
+
* filters/options object (e.g. `invalidateQueries({ queryKey: ['post', idGetter] })`) — methods like
|
|
46
|
+
* `getQueryData` that take the `queryKey` array as their own argument do not unwrap getter entries there,
|
|
47
|
+
* and the getter function itself ends up in the cache key.
|
|
48
|
+
*
|
|
42
49
|
* Install one on your app with `VueQueryPlugin`, or retrieve it with `useQueryClient`.
|
|
43
50
|
*/
|
|
44
51
|
export class QueryClient extends QC {
|