@tanstack/solid-query 5.103.2 → 5.103.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -22,8 +22,8 @@ Hooks for fetching, caching and updating asynchronous data in Solid
22
22
  <img alt="#TanStack" src="https://img.shields.io/twitter/url?color=%2308a0e9&label=%23TanStack&style=social&url=https%3A%2F%2Ftwitter.com%2Fintent%2Ftweet%3Fbutton_hashtag%3DTanStack">
23
23
  </a><a href="https://discord.com/invite/WrRKjPJ" target="\_parent">
24
24
  <img alt="" src="https://img.shields.io/badge/Discord-TanStack-%235865F2" />
25
- </a><a href="https://github.com/TanStack/query/actions?query=workflow%3A%ci%22">
26
- <img src="https://github.com/TanStack/query/workflows/ci/badge.svg" />
25
+ </a><a href="https://github.com/TanStack/query/actions/workflows/release.yml?query=branch%3Amain">
26
+ <img alt="Release status" src="https://github.com/TanStack/query/actions/workflows/release.yml/badge.svg?branch=main" />
27
27
  </a><a href="https://www.npmjs.com/package/@tanstack/query-core" target="\_parent">
28
28
  <img alt="" src="https://img.shields.io/npm/dm/@tanstack/query-core.svg" />
29
29
  </a><a href="https://bundlejs.com/?q=%40tanstack%2Fsolid-query&config=%7B%22esbuild%22%3A%7B%22external%22%3A%5B%22solid-js%22%2C%5D%7D%7D&badge=" target="\_parent">
package/build/dev.cjs CHANGED
@@ -251,7 +251,7 @@ function useBaseQuery(options, Observer, queryClient) {
251
251
  if (!restoring && !solid_js_web.isServer) refetch();
252
252
  }, { defer: true }));
253
253
  (0, solid_js.onCleanup)(() => {
254
- if (solid_js_web.isServer && queryResource.loading) {
254
+ if (solid_js_web.isServer && queryResource.state === "pending") {
255
255
  unsubscribeQueued = true;
256
256
  return;
257
257
  }
package/build/dev.js CHANGED
@@ -251,7 +251,7 @@ function useBaseQuery(options, Observer, queryClient) {
251
251
  if (!restoring && !isServer) refetch();
252
252
  }, { defer: true }));
253
253
  onCleanup(() => {
254
- if (isServer && queryResource.loading) {
254
+ if (isServer && queryResource.state === "pending") {
255
255
  unsubscribeQueued = true;
256
256
  return;
257
257
  }
package/build/index.cjs CHANGED
@@ -1 +1,3 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@tanstack/query-core"),t=require("solid-js"),n=require("solid-js/web"),r=require("solid-js/store");const i=(0,t.createContext)(void 0),a=`No QueryClient set, use QueryClientProvider to set one`,o=e=>{if(e)return e;let n=(0,t.useContext)(i);if(!n)throw Error(a);return n()},s=e=>{let n=(0,t.useContext)(i);return()=>{let t=e?.();if(t)return t;if(!n)throw Error(a);return n()}},c=e=>((0,t.createRenderEffect)(t=>(t?.(),e.client.mount(),e.client.unmount.bind(e.client))),(0,t.onCleanup)(()=>e.client.unmount()),(0,n.createComponent)(i.Provider,{value:()=>e.client,get children(){return e.children}})),l=(0,t.createContext)(()=>!1),u=()=>(0,t.useContext)(l),d=l.Provider;function f(e,t,n,i){if(n===!1)return t;if(typeof n==`function`){let r=n(e.data,t.data);return{...t,data:r}}let a=t.data;if(e.data===void 0)try{a=structuredClone(a)}catch{}let o=(0,r.reconcile)(a,{key:n})(e.data);return{...t,data:o}}const p=(e,t)=>{if(!n.isServer)return t;let i={...(0,r.unwrap)(t),refetch:void 0};return`fetchNextPage`in t&&(i.fetchNextPage=void 0,i.fetchPreviousPage=void 0),i.hydrationData={state:e.state,queryKey:e.queryKey,queryHash:e.queryHash,...e.meta&&{meta:e.meta}},i};function m(i,a,o){let c=s(o),l=(0,t.createMemo)(()=>c()),d=u(),m=!1,h=(0,t.createMemo)(()=>{let e=l().defaultQueryOptions(i());return e._optimisticResults=d()?`isRestoring`:`optimistic`,e.structuralSharing=!1,n.isServer&&(e.retry=!1,e.throwOnError=!0),e}),g=h(),[_,v]=(0,t.createSignal)(new a(l(),h())),y=_().getOptimisticResult(h()),[b,x]=(0,r.createStore)(y),S=(t,n)=>_().subscribe(r=>{e.notifyManager.batchCalls(()=>{let e=_().getCurrentQuery(),i=p(e,r);r.data!==void 0&&i.isError?(n(i.error),C()):(t(i),C())})()}),C=()=>{m&&=(D?.(),!1)},w=()=>_().subscribe(e=>{y=e,queueMicrotask(()=>{D&&A()})});function T(e){let t=_().options,n=t.reconcile;x(r=>f(r,e,n!==void 0&&n,t.queryHash))}function E(){return[()=>b,e=>{let t=(0,r.unwrap)(b);if(typeof e==`function`&&(e=e(t)),e?.hydrationData){let{hydrationData:t,...n}=e;e=n}T(e)}]}let D=null,O=null,[k,{refetch:A}]=(0,t.createResource)(()=>{let t=_();return new Promise((r,i)=>{if(O=r,n.isServer?D=S(r,i):!D&&!d()&&(D=w()),t.updateResult(),y.isError&&!y.isFetching&&!d()&&(0,e.shouldThrowError)(t.options.throwOnError,[y.error,t.getCurrentQuery()]))return T(y),i(y.error);if(!y.isLoading)return O=null,r(p(t.getCurrentQuery(),y));T(y)})},{storage:E,get deferStream(){return i().deferStream},onHydrated(t,n){if(n.value&&`hydrationData`in n.value&&(0,e.hydrate)(l(),{queries:[{...n.value.hydrationData}]}),D)return;let r={...g};(g.staleTime||!g.initialData)&&n.value&&(r.refetchOnMount=!1),_().setOptions(r),T(_().getOptimisticResult(r)),D=w()}});return(0,t.createComputed)((0,t.on)(l,e=>{D&&D();let t=new a(e,h());D=w(),v(t)},{defer:!0})),(0,t.createComputed)((0,t.on)(d,e=>{!e&&!n.isServer&&A()},{defer:!0})),(0,t.onCleanup)(()=>{if(n.isServer&&k.loading){m=!0;return}D&&=(D(),null),O&&!n.isServer&&(O(y),O=null)}),(0,t.createComputed)((0,t.on)([_,h],([e,t])=>{e.setOptions(t),T(e.getOptimisticResult(t)),A()},{defer:!0})),new Proxy(b,{get(e,t){return t===`data`?b.data===void 0?k()?.data:k.latest?.data:Reflect.get(e,t)}})}function h(n,r){return m((0,t.createMemo)(()=>n()),e.QueryObserver,r)}function g(n,r){return m((0,t.createMemo)(()=>n()),e.InfiniteQueryObserver,r)}function _(n,i){let a=s(i),o=(0,t.createMemo)(()=>a()),c=new e.MutationObserver(o(),n()),l=(...t)=>{c.mutate(t[0],t[1]).catch(e.noop)},[u,d]=(0,r.createStore)({...c.getCurrentResult(),mutate:l,mutateAsync:c.getCurrentResult().mutate});(0,t.createComputed)(()=>{c.setOptions(n())}),(0,t.createComputed)((0,t.on)(()=>u.status,()=>{if(u.isError&&(0,e.shouldThrowError)(c.options.throwOnError,[u.error]))throw u.error}));let f=c.subscribe(e=>{d({...e,mutate:l,mutateAsync:e.mutate})});return(0,t.onCleanup)(f),u}function v(n,i){let a=s(i),o=(0,t.createMemo)(()=>a()),c=u(),l=(0,t.createMemo)(()=>n().queries.map(e=>(0,t.mergeProps)(o().defaultQueryOptions(e),{get _optimisticResults(){return c()?`isRestoring`:`optimistic`}}))),d=new e.QueriesObserver(o(),l(),n().combine?{combine:n().combine}:void 0),[f,p]=(0,r.createStore)(d.getOptimisticResult(l(),n().combine)[1]());(0,t.createRenderEffect)((0,t.on)(()=>n().queries.length,()=>p(d.getOptimisticResult(l(),n().combine)[1]())));let m=(0,t.createMemo)((0,t.on)(()=>f.length,()=>f.map(e=>(0,t.createResource)(()=>new Promise(t=>{e.isFetching&&e.isLoading||t((0,r.unwrap)(e.data))})))));(0,t.batch)(()=>{let e=m();for(let t=0;t<e.length;t++){let n=e[t];n[1].mutate(()=>(0,r.unwrap)(f[t].data)),n[1].refetch()}});let h=[],g=()=>d.subscribe(e=>{h.push(()=>{(0,t.batch)(()=>{let t=m();for(let n=0;n<t.length;n++){let i=t[n],a={...(0,r.unwrap)(e[n])};p(n,(0,r.unwrap)(a)),i[1].mutate(()=>(0,r.unwrap)(f[n].data)),i[1].refetch()}})}),queueMicrotask(()=>{let e=h.pop();e&&e(),h=[]})}),_=e.noop;(0,t.createComputed)(t=>(t?.(),_=c()?e.noop:g(),()=>queueMicrotask(_))),(0,t.onCleanup)(_),(0,t.onMount)(()=>{d.setQueries(l(),n().combine?{combine:n().combine}:void 0)}),(0,t.createComputed)(()=>{d.setQueries(l(),n().combine?{combine:n().combine}:void 0)});let v=e=>({get(t,n){return n===`data`?m()[e][0]():Reflect.get(t,n)}}),y=()=>f.map((e,t)=>new Proxy(e,v(t))),[b,x]=(0,r.createStore)(y());return(0,t.createRenderEffect)(()=>x(y())),b}var y=class extends e.QueryClient{constructor(e={}){super(e)}};function b(e){return e}function x(e,n){let r=s(n),i=(0,t.createMemo)(()=>r()),a=(0,t.createMemo)(()=>i().getQueryCache()),[o,c]=(0,t.createSignal)(i().isFetching(e?.()));return(0,t.createEffect)(()=>{c(i().isFetching(e?.()));let n=a().subscribe(()=>{c(i().isFetching(e?.()))});(0,t.onCleanup)(n)}),o}function S(e){return e}function C(e){return e}function w(e,n){let r=s(n),i=(0,t.createMemo)(()=>r()),a=(0,t.createMemo)(()=>i().getMutationCache()),[o,c]=(0,t.createSignal)(i().isMutating(e?.()));return(0,t.createEffect)(()=>{c(i().isMutating(e?.()));let n=a().subscribe(()=>{c(i().isMutating(e?.()))});(0,t.onCleanup)(n)}),o}function T(e,t){return e.findAll(t.filters).map(e=>t.select?t.select(e):e.state)}function E(n=()=>({}),r){let i=s(r),a=(0,t.createMemo)(()=>i()),o=(0,t.createMemo)(()=>a().getMutationCache()),[c,l]=(0,t.createSignal)(T(o(),n()));return(0,t.createEffect)(()=>{let r=o().subscribe(()=>{let t=(0,e.replaceEqualDeep)(c(),T(o(),n()));c()!==t&&l(t)});(0,t.onCleanup)(r)}),c}const D=h,O=g,k=_,A=v;exports.IsRestoringProvider=d,exports.QueryClient=y,exports.QueryClientContext=i,exports.QueryClientProvider=c,exports.createInfiniteQuery=O,exports.createIsFetching=x,exports.useIsFetching=x,exports.createIsMutating=w,exports.useIsMutating=w,exports.createMutation=k,exports.createMutationState=E,exports.useMutationState=E,exports.createQueries=A,exports.createQuery=D,exports.infiniteQueryOptions=S,exports.mutationOptions=C,exports.queryOptions=b,exports.useInfiniteQuery=g,exports.useIsRestoring=u,exports.useMutation=_,exports.useQueries=v,exports.useQuery=h,exports.useQueryClient=o,Object.keys(e).forEach(function(t){t!=="default"&&!Object.prototype.hasOwnProperty.call(exports,t)&&Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})});
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@tanstack/query-core"),t=require("solid-js"),n=require("solid-js/web"),r=require("solid-js/store");const i=(0,t.createContext)(void 0),a=`No QueryClient set, use QueryClientProvider to set one`,o=e=>{if(e)return e;let n=(0,t.useContext)(i);if(!n)throw Error(a);return n()},s=e=>{let n=(0,t.useContext)(i);return()=>{let t=e?.();if(t)return t;if(!n)throw Error(a);return n()}},c=e=>((0,t.createRenderEffect)(t=>(t?.(),e.client.mount(),e.client.unmount.bind(e.client))),(0,t.onCleanup)(()=>e.client.unmount()),(0,n.createComponent)(i.Provider,{value:()=>e.client,get children(){return e.children}})),l=(0,t.createContext)(()=>!1),u=()=>(0,t.useContext)(l),d=l.Provider;function f(e,t,n,i){if(n===!1)return t;if(typeof n==`function`){let r=n(e.data,t.data);return{...t,data:r}}let a=t.data;if(e.data===void 0)try{a=structuredClone(a)}catch{}let o=(0,r.reconcile)(a,{key:n})(e.data);return{...t,data:o}}const p=(e,t)=>{if(!n.isServer)return t;let i={...(0,r.unwrap)(t),refetch:void 0};return`fetchNextPage`in t&&(i.fetchNextPage=void 0,i.fetchPreviousPage=void 0),i.hydrationData={state:e.state,queryKey:e.queryKey,queryHash:e.queryHash,...e.meta&&{meta:e.meta}},i};function m(i,a,o){let c=s(o),l=(0,t.createMemo)(()=>c()),d=u(),m=!1,h=(0,t.createMemo)(()=>{let e=l().defaultQueryOptions(i());return e._optimisticResults=d()?`isRestoring`:`optimistic`,e.structuralSharing=!1,n.isServer&&(e.retry=!1,e.throwOnError=!0),e}),g=h(),[_,v]=(0,t.createSignal)(new a(l(),h())),y=_().getOptimisticResult(h()),[b,x]=(0,r.createStore)(y),S=(t,n)=>_().subscribe(r=>{e.notifyManager.batchCalls(()=>{let e=_().getCurrentQuery(),i=p(e,r);r.data!==void 0&&i.isError?(n(i.error),C()):(t(i),C())})()}),C=()=>{m&&=(D?.(),!1)},w=()=>_().subscribe(e=>{y=e,queueMicrotask(()=>{D&&A()})});function T(e){let t=_().options,n=t.reconcile;x(r=>f(r,e,n!==void 0&&n,t.queryHash))}function E(){return[()=>b,e=>{let t=(0,r.unwrap)(b);if(typeof e==`function`&&(e=e(t)),e?.hydrationData){let{hydrationData:t,...n}=e;e=n}T(e)}]}let D=null,O=null,[k,{refetch:A}]=(0,t.createResource)(()=>{let t=_();return new Promise((r,i)=>{if(O=r,n.isServer?D=S(r,i):!D&&!d()&&(D=w()),t.updateResult(),y.isError&&!y.isFetching&&!d()&&(0,e.shouldThrowError)(t.options.throwOnError,[y.error,t.getCurrentQuery()]))return T(y),i(y.error);if(!y.isLoading)return O=null,r(p(t.getCurrentQuery(),y));T(y)})},{storage:E,get deferStream(){return i().deferStream},onHydrated(t,n){if(n.value&&`hydrationData`in n.value&&(0,e.hydrate)(l(),{queries:[{...n.value.hydrationData}]}),D)return;let r={...g};(g.staleTime||!g.initialData)&&n.value&&(r.refetchOnMount=!1),_().setOptions(r),T(_().getOptimisticResult(r)),D=w()}});return(0,t.createComputed)((0,t.on)(l,e=>{D&&D();let t=new a(e,h());D=w(),v(t)},{defer:!0})),(0,t.createComputed)((0,t.on)(d,e=>{!e&&!n.isServer&&A()},{defer:!0})),(0,t.onCleanup)(()=>{if(n.isServer&&k.state===`pending`){m=!0;return}D&&=(D(),null),O&&!n.isServer&&(O(y),O=null)}),(0,t.createComputed)((0,t.on)([_,h],([e,t])=>{e.setOptions(t),T(e.getOptimisticResult(t)),A()},{defer:!0})),new Proxy(b,{get(e,t){return t===`data`?b.data===void 0?k()?.data:k.latest?.data:Reflect.get(e,t)}})}function h(n,r){return m((0,t.createMemo)(()=>n()),e.QueryObserver,r)}function g(n,r){return m((0,t.createMemo)(()=>n()),e.InfiniteQueryObserver,r)}function _(n,i){let a=s(i),o=(0,t.createMemo)(()=>a()),c=new e.MutationObserver(o(),n()),l=(...t)=>{c.mutate(t[0],t[1]).catch(e.noop)},[u,d]=(0,r.createStore)({...c.getCurrentResult(),mutate:l,mutateAsync:c.getCurrentResult().mutate});(0,t.createComputed)(()=>{c.setOptions(n())}),(0,t.createComputed)((0,t.on)(()=>u.status,()=>{if(u.isError&&(0,e.shouldThrowError)(c.options.throwOnError,[u.error]))throw u.error}));let f=c.subscribe(e=>{d({...e,mutate:l,mutateAsync:e.mutate})});return(0,t.onCleanup)(f),u}function v(n,i){let a=s(i),o=(0,t.createMemo)(()=>a()),c=u(),l=(0,t.createMemo)(()=>n().queries.map(e=>(0,t.mergeProps)(o().defaultQueryOptions(e),{get _optimisticResults(){return c()?`isRestoring`:`optimistic`}}))),d=new e.QueriesObserver(o(),l(),n().combine?{combine:n().combine}:void 0),[f,p]=(0,r.createStore)(d.getOptimisticResult(l(),n().combine)[1]());(0,t.createRenderEffect)((0,t.on)(()=>n().queries.length,()=>p(d.getOptimisticResult(l(),n().combine)[1]())));let m=(0,t.createMemo)((0,t.on)(()=>f.length,()=>f.map(e=>(0,t.createResource)(()=>new Promise(t=>{e.isFetching&&e.isLoading||t((0,r.unwrap)(e.data))})))));(0,t.batch)(()=>{let e=m();for(let t=0;t<e.length;t++){let n=e[t];n[1].mutate(()=>(0,r.unwrap)(f[t].data)),n[1].refetch()}});let h=[],g=()=>d.subscribe(e=>{h.push(()=>{(0,t.batch)(()=>{let t=m();for(let n=0;n<t.length;n++){let i=t[n],a={...(0,r.unwrap)(e[n])};p(n,(0,r.unwrap)(a)),i[1].mutate(()=>(0,r.unwrap)(f[n].data)),i[1].refetch()}})}),queueMicrotask(()=>{let e=h.pop();e&&e(),h=[]})}),_=e.noop;(0,t.createComputed)(t=>(t?.(),_=c()?e.noop:g(),()=>queueMicrotask(_))),(0,t.onCleanup)(_),(0,t.onMount)(()=>{d.setQueries(l(),n().combine?{combine:n().combine}:void 0)}),(0,t.createComputed)(()=>{d.setQueries(l(),n().combine?{combine:n().combine}:void 0)});let v=e=>({get(t,n){return n===`data`?m()[e][0]():Reflect.get(t,n)}}),y=()=>f.map((e,t)=>new Proxy(e,v(t))),[b,x]=(0,r.createStore)(y());return(0,t.createRenderEffect)(()=>x(y())),b}var y=class extends e.QueryClient{constructor(e={}){super(e)}};function b(e){return e}function x(e,n){let r=s(n),i=(0,t.createMemo)(()=>r()),a=(0,t.createMemo)(()=>i().getQueryCache()),[o,c]=(0,t.createSignal)(i().isFetching(e?.()));return(0,t.createEffect)(()=>{c(i().isFetching(e?.()));let n=a().subscribe(()=>{c(i().isFetching(e?.()))});(0,t.onCleanup)(n)}),o}function S(e){return e}function C(e){return e}function w(e,n){let r=s(n),i=(0,t.createMemo)(()=>r()),a=(0,t.createMemo)(()=>i().getMutationCache()),[o,c]=(0,t.createSignal)(i().isMutating(e?.()));return(0,t.createEffect)(()=>{c(i().isMutating(e?.()));let n=a().subscribe(()=>{c(i().isMutating(e?.()))});(0,t.onCleanup)(n)}),o}function T(e,t){return e.findAll(t.filters).map(e=>t.select?t.select(e):e.state)}function E(n=()=>({}),r){let i=s(r),a=(0,t.createMemo)(()=>i()),o=(0,t.createMemo)(()=>a().getMutationCache()),[c,l]=(0,t.createSignal)(T(o(),n()));return(0,t.createEffect)(()=>{let r=o().subscribe(()=>{let t=(0,e.replaceEqualDeep)(c(),T(o(),n()));c()!==t&&l(t)});(0,t.onCleanup)(r)}),c}
2
+ /* istanbul ignore file */
3
+ const D=h,O=g,k=_,A=v;exports.IsRestoringProvider=d,exports.QueryClient=y,exports.QueryClientContext=i,exports.QueryClientProvider=c,exports.createInfiniteQuery=O,exports.createIsFetching=x,exports.useIsFetching=x,exports.createIsMutating=w,exports.useIsMutating=w,exports.createMutation=k,exports.createMutationState=E,exports.useMutationState=E,exports.createQueries=A,exports.createQuery=D,exports.infiniteQueryOptions=S,exports.mutationOptions=C,exports.queryOptions=b,exports.useInfiniteQuery=g,exports.useIsRestoring=u,exports.useMutation=_,exports.useQueries=v,exports.useQuery=h,exports.useQueryClient=o,Object.keys(e).forEach(function(t){t!=="default"&&!Object.prototype.hasOwnProperty.call(exports,t)&&Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})});
package/build/index.d.cts CHANGED
@@ -131,14 +131,16 @@ type UseBaseQueryResult<TData = unknown, TError = DefaultError> = QueryObserverR
131
131
  */
132
132
  type UseQueryResult<TData = unknown, TError = DefaultError> = UseBaseQueryResult<TData, TError>;
133
133
  /**
134
- * The object `useQuery` returns when `initialData` guarantees `data` is never `undefined`.
134
+ * The object `useQuery` returns when `initialData` guarantees `data` is never `undefined` (unless a
135
+ * `select` changes `TData` to include `undefined`).
135
136
  *
136
137
  * @template TData - The type `data` ends up as, after `select` runs (if set).
137
138
  * @template TError - The type of errors this query may hold.
138
139
  */
139
140
  type DefinedUseBaseQueryResult<TData = unknown, TError = DefaultError> = DefinedQueryObserverResult<TData, TError>;
140
141
  /**
141
- * The object `useQuery` returns when `initialData` guarantees `data` is never `undefined`.
142
+ * The object `useQuery` returns when `initialData` guarantees `data` is never `undefined` (unless a
143
+ * `select` changes `TData` to include `undefined`).
142
144
  *
143
145
  * @template TData - The type `data` ends up as, after `select` runs (if set).
144
146
  * @template TError - The type of errors this query may hold.
@@ -198,7 +200,8 @@ type UseInfiniteQueryOptions<TQueryFnData = unknown, TError = DefaultError, TDat
198
200
  */
199
201
  type UseInfiniteQueryResult<TData = unknown, TError = DefaultError> = InfiniteQueryObserverResult<TData, TError>;
200
202
  /**
201
- * The object `useInfiniteQuery` returns when `initialData` guarantees `data` is never `undefined`.
203
+ * The object `useInfiniteQuery` returns when `initialData` guarantees `data` is never `undefined` (unless a
204
+ * `select` changes `TData` to include `undefined`).
202
205
  *
203
206
  * @template TData - The type `data` ends up as, after `select` runs (if set).
204
207
  * @template TError - The type of errors this query may hold.
@@ -281,7 +284,7 @@ type UndefinedInitialDataOptions<TQueryFnData = unknown, TError = DefaultError,
281
284
  }>;
282
285
  /**
283
286
  * The options accepted by the `queryOptions` overload selected when `initialData` is set — `data` is never
284
- * `undefined`.
287
+ * `undefined` (unless a `select` changes `TData` to include `undefined`).
285
288
  *
286
289
  * @template TQueryFnData - The type your `queryFn` resolves to.
287
290
  * @template TError - The type of errors your `queryFn` may throw.
@@ -296,7 +299,8 @@ type DefinedInitialDataOptions<TQueryFnData = unknown, TError = DefaultError, TD
296
299
  * be shared across hooks and imperative APIs such as `queryClient.query`. `options.queryKey` is required and
297
300
  * is the query key to generate options for.
298
301
  *
299
- * This overload is selected when `initialData` is set, so the resulting `data` is never `undefined`.
302
+ * This overload is selected when `initialData` is set, so the resulting `data` is never `undefined` (unless
303
+ * a `select` changes `TData` to include `undefined`).
300
304
  *
301
305
  * @see {@link useQuery} to run a query with these options.
302
306
  * @param options - The {@link DefinedInitialDataOptions} to use — everything you can pass to `useQuery`, with `initialData` set.
@@ -482,7 +486,9 @@ declare function queryOptions<TQueryFnData = unknown, TError = DefaultError, TDa
482
486
  * ```
483
487
  *
484
488
  * @example
485
- * Seeding a detail query from an already-cached list, to skip the loading state:
489
+ * Seeding a detail query from an already-cached list, to skip the loading state. `initialDataUpdatedAt` carries
490
+ * over the list's own fetch time, so that if you set a `staleTime`, it's measured from when the list was
491
+ * fetched rather than from now:
486
492
  * ```tsx
487
493
  * import { useQuery, useQueryClient } from '@tanstack/solid-query'
488
494
  *
@@ -496,6 +502,8 @@ declare function queryOptions<TQueryFnData = unknown, TError = DefaultError, TDa
496
502
  * queryClient
497
503
  * .getQueryData<Array<Post>>(['posts'])
498
504
  * ?.find((post) => post.id === props.postId),
505
+ * initialDataUpdatedAt: () =>
506
+ * queryClient.getQueryState(['posts'])?.dataUpdatedAt,
499
507
  * }))
500
508
  *
501
509
  * return postQuery.isError ? <span>Error: {postQuery.error.message}</span> : <h1>{postQuery.data?.title}</h1>
@@ -538,7 +546,8 @@ declare function useQuery<TQueryFnData = unknown, TError = DefaultError, TData =
538
546
  * Subscribes to a query: a declarative dependency on an asynchronous source of data that is tied to a unique key.
539
547
  * The query runs when the options call for it — `enabled: false` skips the initial fetch.
540
548
  *
541
- * This overload is selected when `initialData` is set, so the resulting `data` is never `undefined`.
549
+ * This overload is selected when `initialData` is set, so the resulting `data` is never `undefined` (unless
550
+ * a `select` changes `TData` to include `undefined`).
542
551
  *
543
552
  * @see {@link queryOptions} to share these options between `useQuery` and imperative APIs like `queryClient.query`.
544
553
  * @param options - An accessor returning the {@link DefinedInitialDataOptions} to use — everything you can
@@ -597,7 +606,7 @@ type UndefinedInitialDataInfiniteOptions<TQueryFnData, TError = DefaultError, TD
597
606
  }>;
598
607
  /**
599
608
  * The options accepted by the `infiniteQueryOptions` overload selected when `initialData` is set — `data` is
600
- * never `undefined`.
609
+ * never `undefined` (unless a `select` changes `TData` to include `undefined`).
601
610
  *
602
611
  * @template TQueryFnData - The type of a single page, as your `queryFn` resolves it.
603
612
  * @template TError - The type of errors your `queryFn` may throw.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../src/QueryClient.ts","../src/types.ts","../src/queryOptions.ts","../src/useQuery.ts","../src/infiniteQueryOptions.ts","../src/useInfiniteQuery.ts","../src/useMutation.ts","../src/useQueries.ts","../src/QueryClientProvider.tsx","../src/useIsFetching.ts","../src/mutationOptions.ts","../src/useIsMutating.ts","../src/useMutationState.ts","../src/isRestoring.ts","../src/index.ts"],"mappings":";;;;;;;;;;;;;;;UAsBiB,qBACf,wBACA,SAAS,cACT,QAAQ,cACR,aAAa,cACb,kBAAkB,WAAW,UAC7B,4BACQ,UACR,uBACE,cACA,QACA,OACA,YACA,WACA;;;;;;;EAUF,+BAGM,SAAS,mBAAmB,SAAS,UAAU;;;;;;;;;;;UAYtC,6BACf,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,UAC7B,8BACQ,UACR,+BACE,cACA,QACA,OACA,WACA;;;;;;;EAUF,+BAGM,SAAS,mBAAmB,SAAS,UAAU;;;;;;;;UAStC,eACf,SAAS,sBACD,iBAAmB;EAC3B,UAAU,UAAU,8BAA8B;;;;;UAMnC,0BA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verOptions","CoreDefaultOptions","QueryCoreClientConfig","QueryCoreClient"],"sources":["../src/QueryClient.ts","../src/types.ts","../src/queryOptions.ts","../src/useQuery.ts","../src/infiniteQueryOptions.ts","../src/useInfiniteQuery.ts","../src/useMutation.ts","../src/useQueries.ts","../src/QueryClientProvider.tsx","../src/useIsFetching.ts","../src/mutationOptions.ts","../src/useIsMutating.ts","../src/useMutationState.ts","../src/isRestoring.ts","../src/index.ts"],"mappings":";;;;;;;;;;;;;;;UAsBiB,qBACf,wBACA,SAAS,cACT,QAAQ,cACR,aAAa,cACb,kBAAkB,WAAW,UAC7B,4BACQ,UACRA,uBACE,cACA,QACA,OACA,YACA,WACA;;;;;;;EAUF,+BACqB,SAAS,mBAAmB,SAAS,UAAU;;;;;;;;;;;UAYrD,6BACf,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,UAC7B,8BACQ,UACRC,+BACE,cACA,QACA,OACA,WACA;;;;;;;EAUF,+BACqB,SAAS,mBAAmB,SAAS,UAAU;;;;;;;;UASrD,eACf,SAAS,sBACDC,iBAAmB;EAC3B,UAAU,UAAU,8BAA8B;;;;;UAMnC,0BAA0BC;EACzC,iBAAiB;;;;;;cAON,oBAAoBC;EACnB,YAAA,SAAQ;;;;;;;;;;;;;;;;UC5EL,oBACf,wBACA,SAAS,cACT,QAAQ,cACR,aAAa,cACb,kBAAkB,WAAW,kBACrB,UACR,qBAAqB,cAAc,QAAQ,OAAO,YAAY;;;;;;;;EAU9D;;;;;;EAMA;;;;;;;;;;;UAYe,aACf,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,kBACrB,oBACR,cACA,QACA,OACA,cACA;;;;;;;;;;;KAaU,gBACV,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,YAC3B,SAAS,aAAa,cAAc,QAAQ,OAAO;;;;;;;;;KAY3C,mBACV,iBACA,SAAS,gBACP,oBAAoB,OAAO;;;;;;;;KASnB,eACV,iBACA,SAAS,gBACP,mBAA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SAAS,KACP,gBAAgB,OAAO,QAAQ,YAAY,mCAG5C,KACD,gBAAgB,OAAO,QAAQ,YAAY;;;;;;;;;;;;;;;;;;;;;;;;iBCxD7B,cACd,UAAU,SAAS,kBACnB,cAAc,SAAS,eACtB;;;KClBE,uBAAuB,YAAY,kBACtC,oBACQ,aACA,cACA,kBACA,oBAGN,SAAS,OAAO,QAAQ,YAAY,mBACpC;KAEC,qBACH,UAAU,eACV,kBAAkB,+BAChB,uBAAuB;EAEzB,UAAU;EACV,UAAU,UAAU,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA8FpB,iBACd,UAAU,eACV,kBAAkB,+BAChB,uBAAuB,UAEzB,UAAS,SAAS,qBAAqB,SAAS,aAChD,cAAc,SAAS,eACtB,SAAS,MAAM;;;;;;;;;;cCtHL,sBAAc;;;;;cAMd,wCAAmB,yBAAA;;;cCsCnB,oBAAW;cAeX,4BAAmB;cAQnB,uBAAc;cAMd,sBAAa"}
package/build/index.d.ts CHANGED
@@ -131,14 +131,16 @@ type UseBaseQueryResult<TData = unknown, TError = DefaultError> = QueryObserverR
131
131
  */
132
132
  type UseQueryResult<TData = unknown, TError = DefaultError> = UseBaseQueryResult<TData, TError>;
133
133
  /**
134
- * The object `useQuery` returns when `initialData` guarantees `data` is never `undefined`.
134
+ * The object `useQuery` returns when `initialData` guarantees `data` is never `undefined` (unless a
135
+ * `select` changes `TData` to include `undefined`).
135
136
  *
136
137
  * @template TData - The type `data` ends up as, after `select` runs (if set).
137
138
  * @template TError - The type of errors this query may hold.
138
139
  */
139
140
  type DefinedUseBaseQueryResult<TData = unknown, TError = DefaultError> = DefinedQueryObserverResult<TData, TError>;
140
141
  /**
141
- * The object `useQuery` returns when `initialData` guarantees `data` is never `undefined`.
142
+ * The object `useQuery` returns when `initialData` guarantees `data` is never `undefined` (unless a
143
+ * `select` changes `TData` to include `undefined`).
142
144
  *
143
145
  * @template TData - The type `data` ends up as, after `select` runs (if set).
144
146
  * @template TError - The type of errors this query may hold.
@@ -198,7 +200,8 @@ type UseInfiniteQueryOptions<TQueryFnData = unknown, TError = DefaultError, TDat
198
200
  */
199
201
  type UseInfiniteQueryResult<TData = unknown, TError = DefaultError> = InfiniteQueryObserverResult<TData, TError>;
200
202
  /**
201
- * The object `useInfiniteQuery` returns when `initialData` guarantees `data` is never `undefined`.
203
+ * The object `useInfiniteQuery` returns when `initialData` guarantees `data` is never `undefined` (unless a
204
+ * `select` changes `TData` to include `undefined`).
202
205
  *
203
206
  * @template TData - The type `data` ends up as, after `select` runs (if set).
204
207
  * @template TError - The type of errors this query may hold.
@@ -281,7 +284,7 @@ type UndefinedInitialDataOptions<TQueryFnData = unknown, TError = DefaultError,
281
284
  }>;
282
285
  /**
283
286
  * The options accepted by the `queryOptions` overload selected when `initialData` is set — `data` is never
284
- * `undefined`.
287
+ * `undefined` (unless a `select` changes `TData` to include `undefined`).
285
288
  *
286
289
  * @template TQueryFnData - The type your `queryFn` resolves to.
287
290
  * @template TError - The type of errors your `queryFn` may throw.
@@ -296,7 +299,8 @@ type DefinedInitialDataOptions<TQueryFnData = unknown, TError = DefaultError, TD
296
299
  * be shared across hooks and imperative APIs such as `queryClient.query`. `options.queryKey` is required and
297
300
  * is the query key to generate options for.
298
301
  *
299
- * This overload is selected when `initialData` is set, so the resulting `data` is never `undefined`.
302
+ * This overload is selected when `initialData` is set, so the resulting `data` is never `undefined` (unless
303
+ * a `select` changes `TData` to include `undefined`).
300
304
  *
301
305
  * @see {@link useQuery} to run a query with these options.
302
306
  * @param options - The {@link DefinedInitialDataOptions} to use — everything you can pass to `useQuery`, with `initialData` set.
@@ -482,7 +486,9 @@ declare function queryOptions<TQueryFnData = unknown, TError = DefaultError, TDa
482
486
  * ```
483
487
  *
484
488
  * @example
485
- * Seeding a detail query from an already-cached list, to skip the loading state:
489
+ * Seeding a detail query from an already-cached list, to skip the loading state. `initialDataUpdatedAt` carries
490
+ * over the list's own fetch time, so that if you set a `staleTime`, it's measured from when the list was
491
+ * fetched rather than from now:
486
492
  * ```tsx
487
493
  * import { useQuery, useQueryClient } from '@tanstack/solid-query'
488
494
  *
@@ -496,6 +502,8 @@ declare function queryOptions<TQueryFnData = unknown, TError = DefaultError, TDa
496
502
  * queryClient
497
503
  * .getQueryData<Array<Post>>(['posts'])
498
504
  * ?.find((post) => post.id === props.postId),
505
+ * initialDataUpdatedAt: () =>
506
+ * queryClient.getQueryState(['posts'])?.dataUpdatedAt,
499
507
  * }))
500
508
  *
501
509
  * return postQuery.isError ? <span>Error: {postQuery.error.message}</span> : <h1>{postQuery.data?.title}</h1>
@@ -538,7 +546,8 @@ declare function useQuery<TQueryFnData = unknown, TError = DefaultError, TData =
538
546
  * Subscribes to a query: a declarative dependency on an asynchronous source of data that is tied to a unique key.
539
547
  * The query runs when the options call for it — `enabled: false` skips the initial fetch.
540
548
  *
541
- * This overload is selected when `initialData` is set, so the resulting `data` is never `undefined`.
549
+ * This overload is selected when `initialData` is set, so the resulting `data` is never `undefined` (unless
550
+ * a `select` changes `TData` to include `undefined`).
542
551
  *
543
552
  * @see {@link queryOptions} to share these options between `useQuery` and imperative APIs like `queryClient.query`.
544
553
  * @param options - An accessor returning the {@link DefinedInitialDataOptions} to use — everything you can
@@ -597,7 +606,7 @@ type UndefinedInitialDataInfiniteOptions<TQueryFnData, TError = DefaultError, TD
597
606
  }>;
598
607
  /**
599
608
  * The options accepted by the `infiniteQueryOptions` overload selected when `initialData` is set — `data` is
600
- * never `undefined`.
609
+ * never `undefined` (unless a `select` changes `TData` to include `undefined`).
601
610
  *
602
611
  * @template TQueryFnData - The type of a single page, as your `queryFn` resolves it.
603
612
  * @template TError - The type of errors your `queryFn` may throw.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/QueryClient.ts","../src/types.ts","../src/queryOptions.ts","../src/useQuery.ts","../src/infiniteQueryOptions.ts","../src/useInfiniteQuery.ts","../src/useMutation.ts","../src/useQueries.ts","../src/QueryClientProvider.tsx","../src/useIsFetching.ts","../src/mutationOptions.ts","../src/useIsMutating.ts","../src/useMutationState.ts","../src/isRestoring.ts","../src/index.ts"],"mappings":";;;;;;;;;;;;;;;UAsBiB,qBACf,wBACA,SAAS,cACT,QAAQ,cACR,aAAa,cACb,kBAAkB,WAAW,UAC7B,4BACQ,UACR,uBACE,cACA,QACA,OACA,YACA,WACA;;;;;;;EAUF,+BAGM,SAAS,mBAAmB,SAAS,UAAU;;;;;;;;;;;UAYtC,6BACf,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,UAC7B,8BACQ,UACR,+BACE,cACA,QACA,OACA,WACA;;;;;;;EAUF,+BAGM,SAAS,mBAAmB,SAAS,UAAU;;;;;;;;UAStC,eACf,SAAS,sBACD,iBAAmB;EAC3B,UAAU,UAAU,8BAA8B;;;;;UAMnC,0BAA0B;EACzC,iBAAiB;;;;;;cAON,oBAAoB;EACnB,YAAA,SAAQ;;;;;;;;;;;;;;;;UChFL,oBACf,wBACA,SAAS,cACT,QAAQ,cACR,aAAa,cACb,kBAAkB,WAAW,kBACrB,UACR,qBAAqB,cAAc,QAAQ,OAAO,YAAY;;;;;;;;EAU9D;;;;;;EAMA;;;;;;;;;;;UAYe,aACf,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,kBACrB,oBACR,cACA,QACA,OACA,cACA;;;;;;;;;;;KAaU,gBACV,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,YAC3B,SAAS,aAAa,cAAc,QAAQ,OAAO;;;;;;;;;KAY3C,mBACV,iBACA,SAAS,gBACP,oBAAoB,OAAO;;;;;;;;KASnB,eACV,iBACA,SAAS,gBACP,mBAAmB,OAAO;;;;;;;KAQlB,0BACV,iBACA,SAAS,gBACP,2BAA2B,OAAO;;;;;;;KAQ1B,sBACV,iBACA,SAAS,gBACP,0BAA0B,OAAO;;;;;;;;;;UAYpB,qBACf,wBACA,SAAS,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;KClBE,uBAAuB,YAAY,kBACtC,oBACQ,aACA,cACA,kBACA,oBAGN,SAAS,OAAO,QAAQ,YAAY,mBACpC;KAEC,qBACH,UAAU,eACV,kBAAkB,+BAChB,uBAAuB;EAEzB,UAAU;EACV,UAAU,UAAU,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA8FpB,iBACd,UAAU,eACV,kBAAkB,+BAChB,uBAAuB,UAEzB,UAAS,SAAS,qBAAqB,SAAS,aAChD,cAAc,SAAS,eACtB,SAAS,MAAM;;;;;;;;;;cCtHL,sBAAc;;;;;cAMd,wCAAmB,yBAAA;;;cCsCnB,oBAAW;cAeX,4BAAmB;cAQnB,uBAAc;cAMd,sBAAa"}
1
+ {"version":3,"file":"index.d.ts","names":["QueryCoreObserverOptions","QueryCoreInfiniteQueryObserverOptions","CoreDefaultOptions","QueryCoreClientConfig","QueryCoreClient"],"sources":["../src/QueryClient.ts","../src/types.ts","../src/queryOptions.ts","../src/useQuery.ts","../src/infiniteQueryOptions.ts","../src/useInfiniteQuery.ts","../src/useMutation.ts","../src/useQueries.ts","../src/QueryClientProvider.tsx","../src/useIsFetching.ts","../src/mutationOptions.ts","../src/useIsMutating.ts","../src/useMutationState.ts","../src/isRestoring.ts","../src/index.ts"],"mappings":";;;;;;;;;;;;;;;UAsBiB,qBACf,wBACA,SAAS,cACT,QAAQ,cACR,aAAa,cACb,kBAAkB,WAAW,UAC7B,4BACQ,UACRA,uBACE,cACA,QACA,OACA,YACA,WACA;;;;;;;EAUF,+BACqB,SAAS,mBAAmB,SAAS,UAAU;;;;;;;;;;;UAYrD,6BACf,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,UAC7B,8BACQ,UACRC,+BACE,cACA,QACA,OACA,WACA;;;;;;;EAUF,+BACqB,SAAS,mBAAmB,SAAS,UAAU;;;;;;;;UASrD,eACf,SAAS,sBACDC,iBAAmB;EA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GED
@@ -1,2 +1,4 @@
1
- import{InfiniteQueryObserver as e,MutationObserver as t,QueriesObserver as n,QueryClient as r,QueryObserver as i,hydrate as a,noop as o,notifyManager as s,replaceEqualDeep as c,shouldThrowError as l}from"@tanstack/query-core";import{batch as u,createComputed as d,createContext as f,createEffect as p,createMemo as m,createRenderEffect as h,createResource as g,createSignal as _,mergeProps as v,on as y,onCleanup as b,onMount as x,useContext as S}from"solid-js";import{createComponent as C,isServer as w}from"solid-js/web";import{createStore as T,reconcile as E,unwrap as D}from"solid-js/store";export*from"@tanstack/query-core";const O=f(void 0),k=`No QueryClient set, use QueryClientProvider to set one`,A=e=>{if(e)return e;let t=S(O);if(!t)throw Error(k);return t()},j=e=>{let t=S(O);return()=>{let n=e?.();if(n)return n;if(!t)throw Error(k);return t()}},M=e=>(h(t=>(t?.(),e.client.mount(),e.client.unmount.bind(e.client))),b(()=>e.client.unmount()),C(O.Provider,{value:()=>e.client,get children(){return e.children}})),N=f(()=>!1),P=()=>S(N),F=N.Provider;function I(e,t,n,r){if(n===!1)return t;if(typeof n==`function`){let r=n(e.data,t.data);return{...t,data:r}}let i=t.data;if(e.data===void 0)try{i=structuredClone(i)}catch{}let a=E(i,{key:n})(e.data);return{...t,data:a}}const L=(e,t)=>{if(!w)return t;let n={...D(t),refetch:void 0};return`fetchNextPage`in t&&(n.fetchNextPage=void 0,n.fetchPreviousPage=void 0),n.hydrationData={state:e.state,queryKey:e.queryKey,queryHash:e.queryHash,...e.meta&&{meta:e.meta}},n};function R(e,t,n){let r=j(n),i=m(()=>r()),o=P(),c=!1,u=m(()=>{let t=i().defaultQueryOptions(e());return t._optimisticResults=o()?`isRestoring`:`optimistic`,t.structuralSharing=!1,w&&(t.retry=!1,t.throwOnError=!0),t}),f=u(),[p,h]=_(new t(i(),u())),v=p().getOptimisticResult(u()),[x,S]=T(v),C=(e,t)=>p().subscribe(n=>{s.batchCalls(()=>{let r=p().getCurrentQuery(),i=L(r,n);n.data!==void 0&&i.isError?(t(i.error),E()):(e(i),E())})()}),E=()=>{c&&=(M?.(),!1)},O=()=>p().subscribe(e=>{v=e,queueMicrotask(()=>{M&&R()})});function k(e){let t=p().options,n=t.reconcile;S(r=>I(r,e,n!==void 0&&n,t.queryHash))}function A(){return[()=>x,e=>{let t=D(x);if(typeof e==`function`&&(e=e(t)),e?.hydrationData){let{hydrationData:t,...n}=e;e=n}k(e)}]}let M=null,N=null,[F,{refetch:R}]=g(()=>{let e=p();return new Promise((t,n)=>{if(N=t,w?M=C(t,n):!M&&!o()&&(M=O()),e.updateResult(),v.isError&&!v.isFetching&&!o()&&l(e.options.throwOnError,[v.error,e.getCurrentQuery()]))return k(v),n(v.error);if(!v.isLoading)return N=null,t(L(e.getCurrentQuery(),v));k(v)})},{storage:A,get deferStream(){return e().deferStream},onHydrated(e,t){if(t.value&&`hydrationData`in t.value&&a(i(),{queries:[{...t.value.hydrationData}]}),M)return;let n={...f};(f.staleTime||!f.initialData)&&t.value&&(n.refetchOnMount=!1),p().setOptions(n),k(p().getOptimisticResult(n)),M=O()}});return d(y(i,e=>{M&&M();let n=new t(e,u());M=O(),h(n)},{defer:!0})),d(y(o,e=>{!e&&!w&&R()},{defer:!0})),b(()=>{if(w&&F.loading){c=!0;return}M&&=(M(),null),N&&!w&&(N(v),N=null)}),d(y([p,u],([e,t])=>{e.setOptions(t),k(e.getOptimisticResult(t)),R()},{defer:!0})),new Proxy(x,{get(e,t){return t===`data`?x.data===void 0?F()?.data:F.latest?.data:Reflect.get(e,t)}})}function z(e,t){return R(m(()=>e()),i,t)}function B(t,n){return R(m(()=>t()),e,n)}function V(e,n){let r=j(n),i=m(()=>r()),a=new t(i(),e()),s=(...e)=>{a.mutate(e[0],e[1]).catch(o)},[c,u]=T({...a.getCurrentResult(),mutate:s,mutateAsync:a.getCurrentResult().mutate});d(()=>{a.setOptions(e())}),d(y(()=>c.status,()=>{if(c.isError&&l(a.options.throwOnError,[c.error]))throw c.error}));let f=a.subscribe(e=>{u({...e,mutate:s,mutateAsync:e.mutate})});return b(f),c}function H(e,t){let r=j(t),i=m(()=>r()),a=P(),s=m(()=>e().queries.map(e=>v(i().defaultQueryOptions(e),{get _optimisticResults(){return a()?`isRestoring`:`optimistic`}}))),c=new n(i(),s(),e().combine?{combine:e().combine}:void 0),[l,f]=T(c.getOptimisticResult(s(),e().combine)[1]());h(y(()=>e().queries.length,()=>f(c.getOptimisticResult(s(),e().combine)[1]())));let p=m(y(()=>l.length,()=>l.map(e=>g(()=>new Promise(t=>{e.isFetching&&e.isLoading||t(D(e.data))})))));u(()=>{let e=p();for(let t=0;t<e.length;t++){let n=e[t];n[1].mutate(()=>D(l[t].data)),n[1].refetch()}});let _=[],S=()=>c.subscribe(e=>{_.push(()=>{u(()=>{let t=p();for(let n=0;n<t.length;n++){let r=t[n],i={...D(e[n])};f(n,D(i)),r[1].mutate(()=>D(l[n].data)),r[1].refetch()}})}),queueMicrotask(()=>{let e=_.pop();e&&e(),_=[]})}),C=o;d(e=>(e?.(),C=a()?o:S(),()=>queueMicrotask(C))),b(C),x(()=>{c.setQueries(s(),e().combine?{combine:e().combine}:void 0)}),d(()=>{c.setQueries(s(),e().combine?{combine:e().combine}:void 0)});let w=e=>({get(t,n){return n===`data`?p()[e][0]():Reflect.get(t,n)}}),E=()=>l.map((e,t)=>new Proxy(e,w(t))),[O,k]=T(E());return h(()=>k(E())),O}var U=class extends r{constructor(e={}){super(e)}};function W(e){return e}function G(e,t){let n=j(t),r=m(()=>n()),i=m(()=>r().getQueryCache()),[a,o]=_(r().isFetching(e?.()));return p(()=>{o(r().isFetching(e?.()));let t=i().subscribe(()=>{o(r().isFetching(e?.()))});b(t)}),a}function K(e){return e}function q(e){return e}function J(e,t){let n=j(t),r=m(()=>n()),i=m(()=>r().getMutationCache()),[a,o]=_(r().isMutating(e?.()));return p(()=>{o(r().isMutating(e?.()));let t=i().subscribe(()=>{o(r().isMutating(e?.()))});b(t)}),a}function Y(e,t){return e.findAll(t.filters).map(e=>t.select?t.select(e):e.state)}function X(e=()=>({}),t){let n=j(t),r=m(()=>n()),i=m(()=>r().getMutationCache()),[a,o]=_(Y(i(),e()));return p(()=>{let t=i().subscribe(()=>{let t=c(a(),Y(i(),e()));a()!==t&&o(t)});b(t)}),a}const Z=z,Q=B,$=V,ee=H;export{F as IsRestoringProvider,U as QueryClient,O as QueryClientContext,M as QueryClientProvider,Q as createInfiniteQuery,G as createIsFetching,G as useIsFetching,J as createIsMutating,J as useIsMutating,$ as createMutation,X as createMutationState,X as useMutationState,ee as createQueries,Z as createQuery,K as infiniteQueryOptions,q as mutationOptions,W as queryOptions,B as useInfiniteQuery,P as useIsRestoring,V as useMutation,H as useQueries,z as useQuery,A as useQueryClient};
1
+ import{InfiniteQueryObserver as e,MutationObserver as t,QueriesObserver as n,QueryClient as r,QueryObserver as i,hydrate as a,noop as o,notifyManager as s,replaceEqualDeep as c,shouldThrowError as l}from"@tanstack/query-core";import{batch as u,createComputed as d,createContext as f,createEffect as p,createMemo as m,createRenderEffect as h,createResource as g,createSignal as _,mergeProps as v,on as y,onCleanup as b,onMount as x,useContext as S}from"solid-js";import{createComponent as C,isServer as w}from"solid-js/web";import{createStore as T,reconcile as E,unwrap as D}from"solid-js/store";export*from"@tanstack/query-core";const O=f(void 0),k=`No QueryClient set, use QueryClientProvider to set one`,A=e=>{if(e)return e;let t=S(O);if(!t)throw Error(k);return t()},j=e=>{let t=S(O);return()=>{let n=e?.();if(n)return n;if(!t)throw Error(k);return t()}},M=e=>(h(t=>(t?.(),e.client.mount(),e.client.unmount.bind(e.client))),b(()=>e.client.unmount()),C(O.Provider,{value:()=>e.client,get children(){return e.children}})),N=f(()=>!1),P=()=>S(N),F=N.Provider;function I(e,t,n,r){if(n===!1)return t;if(typeof n==`function`){let r=n(e.data,t.data);return{...t,data:r}}let i=t.data;if(e.data===void 0)try{i=structuredClone(i)}catch{}let a=E(i,{key:n})(e.data);return{...t,data:a}}const L=(e,t)=>{if(!w)return t;let n={...D(t),refetch:void 0};return`fetchNextPage`in t&&(n.fetchNextPage=void 0,n.fetchPreviousPage=void 0),n.hydrationData={state:e.state,queryKey:e.queryKey,queryHash:e.queryHash,...e.meta&&{meta:e.meta}},n};function R(e,t,n){let r=j(n),i=m(()=>r()),o=P(),c=!1,u=m(()=>{let t=i().defaultQueryOptions(e());return t._optimisticResults=o()?`isRestoring`:`optimistic`,t.structuralSharing=!1,w&&(t.retry=!1,t.throwOnError=!0),t}),f=u(),[p,h]=_(new t(i(),u())),v=p().getOptimisticResult(u()),[x,S]=T(v),C=(e,t)=>p().subscribe(n=>{s.batchCalls(()=>{let r=p().getCurrentQuery(),i=L(r,n);n.data!==void 0&&i.isError?(t(i.error),E()):(e(i),E())})()}),E=()=>{c&&=(M?.(),!1)},O=()=>p().subscribe(e=>{v=e,queueMicrotask(()=>{M&&R()})});function k(e){let t=p().options,n=t.reconcile;S(r=>I(r,e,n!==void 0&&n,t.queryHash))}function A(){return[()=>x,e=>{let t=D(x);if(typeof e==`function`&&(e=e(t)),e?.hydrationData){let{hydrationData:t,...n}=e;e=n}k(e)}]}let M=null,N=null,[F,{refetch:R}]=g(()=>{let e=p();return new Promise((t,n)=>{if(N=t,w?M=C(t,n):!M&&!o()&&(M=O()),e.updateResult(),v.isError&&!v.isFetching&&!o()&&l(e.options.throwOnError,[v.error,e.getCurrentQuery()]))return k(v),n(v.error);if(!v.isLoading)return N=null,t(L(e.getCurrentQuery(),v));k(v)})},{storage:A,get deferStream(){return e().deferStream},onHydrated(e,t){if(t.value&&`hydrationData`in t.value&&a(i(),{queries:[{...t.value.hydrationData}]}),M)return;let n={...f};(f.staleTime||!f.initialData)&&t.value&&(n.refetchOnMount=!1),p().setOptions(n),k(p().getOptimisticResult(n)),M=O()}});return d(y(i,e=>{M&&M();let n=new t(e,u());M=O(),h(n)},{defer:!0})),d(y(o,e=>{!e&&!w&&R()},{defer:!0})),b(()=>{if(w&&F.state===`pending`){c=!0;return}M&&=(M(),null),N&&!w&&(N(v),N=null)}),d(y([p,u],([e,t])=>{e.setOptions(t),k(e.getOptimisticResult(t)),R()},{defer:!0})),new Proxy(x,{get(e,t){return t===`data`?x.data===void 0?F()?.data:F.latest?.data:Reflect.get(e,t)}})}function z(e,t){return R(m(()=>e()),i,t)}function B(t,n){return R(m(()=>t()),e,n)}function V(e,n){let r=j(n),i=m(()=>r()),a=new t(i(),e()),s=(...e)=>{a.mutate(e[0],e[1]).catch(o)},[c,u]=T({...a.getCurrentResult(),mutate:s,mutateAsync:a.getCurrentResult().mutate});d(()=>{a.setOptions(e())}),d(y(()=>c.status,()=>{if(c.isError&&l(a.options.throwOnError,[c.error]))throw c.error}));let f=a.subscribe(e=>{u({...e,mutate:s,mutateAsync:e.mutate})});return b(f),c}function H(e,t){let r=j(t),i=m(()=>r()),a=P(),s=m(()=>e().queries.map(e=>v(i().defaultQueryOptions(e),{get _optimisticResults(){return a()?`isRestoring`:`optimistic`}}))),c=new n(i(),s(),e().combine?{combine:e().combine}:void 0),[l,f]=T(c.getOptimisticResult(s(),e().combine)[1]());h(y(()=>e().queries.length,()=>f(c.getOptimisticResult(s(),e().combine)[1]())));let p=m(y(()=>l.length,()=>l.map(e=>g(()=>new Promise(t=>{e.isFetching&&e.isLoading||t(D(e.data))})))));u(()=>{let e=p();for(let t=0;t<e.length;t++){let n=e[t];n[1].mutate(()=>D(l[t].data)),n[1].refetch()}});let _=[],S=()=>c.subscribe(e=>{_.push(()=>{u(()=>{let t=p();for(let n=0;n<t.length;n++){let r=t[n],i={...D(e[n])};f(n,D(i)),r[1].mutate(()=>D(l[n].data)),r[1].refetch()}})}),queueMicrotask(()=>{let e=_.pop();e&&e(),_=[]})}),C=o;d(e=>(e?.(),C=a()?o:S(),()=>queueMicrotask(C))),b(C),x(()=>{c.setQueries(s(),e().combine?{combine:e().combine}:void 0)}),d(()=>{c.setQueries(s(),e().combine?{combine:e().combine}:void 0)});let w=e=>({get(t,n){return n===`data`?p()[e][0]():Reflect.get(t,n)}}),E=()=>l.map((e,t)=>new Proxy(e,w(t))),[O,k]=T(E());return h(()=>k(E())),O}var U=class extends r{constructor(e={}){super(e)}};function W(e){return e}function G(e,t){let n=j(t),r=m(()=>n()),i=m(()=>r().getQueryCache()),[a,o]=_(r().isFetching(e?.()));return p(()=>{o(r().isFetching(e?.()));let t=i().subscribe(()=>{o(r().isFetching(e?.()))});b(t)}),a}function K(e){return e}function q(e){return e}function J(e,t){let n=j(t),r=m(()=>n()),i=m(()=>r().getMutationCache()),[a,o]=_(r().isMutating(e?.()));return p(()=>{o(r().isMutating(e?.()));let t=i().subscribe(()=>{o(r().isMutating(e?.()))});b(t)}),a}function Y(e,t){return e.findAll(t.filters).map(e=>t.select?t.select(e):e.state)}function X(e=()=>({}),t){let n=j(t),r=m(()=>n()),i=m(()=>r().getMutationCache()),[a,o]=_(Y(i(),e()));return p(()=>{let t=i().subscribe(()=>{let t=c(a(),Y(i(),e()));a()!==t&&o(t)});b(t)}),a}
2
+ /* istanbul ignore file */
3
+ const Z=z,Q=B,$=V,ee=H;export{F as IsRestoringProvider,U as QueryClient,O as QueryClientContext,M as QueryClientProvider,Q as createInfiniteQuery,G as createIsFetching,G as useIsFetching,J as createIsMutating,J as useIsMutating,$ as createMutation,X as createMutationState,X as useMutationState,ee as createQueries,Z as createQuery,K as infiniteQueryOptions,q as mutationOptions,W as queryOptions,B as useInfiniteQuery,P as useIsRestoring,V as useMutation,H as useQueries,z as useQuery,A as useQueryClient};
2
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["createContext","createRenderEffect","onCleanup","useContext","QueryClient","Accessor","JSX","QueryClientContext","undefined","queryClientContextError","useQueryClient","queryClient","client","Error","useQueryClientResolver","contextClient","resolvedClient","QueryClientProviderProps","children","Element","QueryClientProvider","props","unmount","mount","bind","_$createComponent","Provider","value","QueryCoreClient"],"sources":["../src/QueryClientProvider.tsx","../src/isRestoring.ts","../src/useBaseQuery.ts","../src/useQuery.ts","../src/useInfiniteQuery.ts","../src/useMutation.ts","../src/useQueries.ts","../src/QueryClient.ts","../src/queryOptions.ts","../src/useIsFetching.ts","../src/infiniteQueryOptions.ts","../src/mutationOptions.ts","../src/useIsMutating.ts","../src/useMutationState.ts","../src/index.ts"],"sourcesContent":["import {\n createContext,\n createRenderEffect,\n onCleanup,\n useContext,\n} from 'solid-js'\nimport type { QueryClient } from './QueryClient'\nimport type { Accessor, JSX } from 'solid-js'\n\n/**\n * The context that `useQueryClient` reads from. `QueryClientProvider` is the normal way to set it.\n */\nexport const QueryClientContext = createContext<\n (() => QueryClient) | undefined\n>(undefined)\n\nconst queryClientContextError =\n 'No QueryClient set, use QueryClientProvider to set one'\n\n/**\n * The `useQueryClient` primitive returns the current `QueryClient` instance.\n *\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will\n * be used.\n * @returns The current `QueryClient` instance.\n * @throws If no `queryClient` argument is passed and no `QueryClientProvider` is found in the component tree.\n */\nexport const useQueryClient = (queryClient?: QueryClient) => {\n if (queryClient) {\n return queryClient\n }\n const client = useContext(QueryClientContext)\n\n if (!client) {\n throw new Error(queryClientContextError)\n }\n\n return client()\n}\n\nexport const useQueryClientResolver = (\n queryClient?: Accessor<QueryClient | undefined>,\n): Accessor<QueryClient> => {\n const contextClient = useContext(QueryClientContext)\n\n return () => {\n const resolvedClient = queryClient?.()\n if (resolvedClient) {\n return resolvedClient\n }\n\n if (!contextClient) {\n throw new Error(queryClientContextError)\n }\n\n return contextClient()\n }\n}\n\n/**\n * The props accepted by `QueryClientProvider`.\n */\nexport type QueryClientProviderProps = {\n /**\n * **Required**\n *\n * The `QueryClient` instance to provide.\n */\n client: QueryClient\n /**\n * The components that get access to the provided `QueryClient`.\n */\n children?: JSX.Element\n}\n\n/**\n * Use the `QueryClientProvider` component to connect and provide a `QueryClient` to your application. Also\n * calls `client.mount()`/`client.unmount()` as this component mounts/unmounts, which subscribes the client to\n * focus/online events (resuming any paused mutations and refetching as needed when the app regains focus or\n * comes back online).\n *\n * @returns The provided `children`, wrapped so they can read the `QueryClient` via `useQueryClient`.\n *\n * @example\n * ```tsx\n * import { QueryClient, QueryClientProvider } from '@tanstack/solid-query'\n *\n * const queryClient = new QueryClient()\n *\n * function App() {\n * return <QueryClientProvider client={queryClient}>...</QueryClientProvider>\n * }\n * ```\n */\nexport const QueryClientProvider = (\n props: QueryClientProviderProps,\n): JSX.Element => {\n createRenderEffect<() => void>((unmount) => {\n unmount?.()\n props.client.mount()\n return props.client.unmount.bind(props.client)\n })\n onCleanup(() => props.client.unmount())\n\n return (\n <QueryClientContext.Provider value={() => props.client}>\n {props.children}\n </QueryClientContext.Provider>\n )\n}\n","import { createContext, useContext } from 'solid-js'\nimport type { Accessor } from 'solid-js'\n\nconst IsRestoringContext = createContext<Accessor<boolean>>(() => false)\n\n/**\n * If you are using `PersistQueryClientProvider`, you can also use the `useIsRestoring` primitive alongside it to\n * check if a restore is currently in progress. `useQuery` and friends also check this internally to avoid\n * race conditions between the restore and mounting queries.\n *\n * @returns An accessor that reads `true` while a persisted client is being restored, `false` otherwise.\n */\nexport const useIsRestoring = () => useContext(IsRestoringContext)\n\n/**\n * The Provider that `PersistQueryClientProvider` uses to signal whether a persisted client is currently\n * being restored, read by `useIsRestoring`.\n */\nexport const IsRestoringProvider = IsRestoringContext.Provider\n","// Had to disable the lint rule because isServer type is defined as false\n// in solid-js/web package. I'll create a GitHub issue with them to see\n// why that happens.\nimport { hydrate, notifyManager, shouldThrowError } from '@tanstack/query-core'\nimport { isServer } from 'solid-js/web'\nimport {\n createComputed,\n createMemo,\n createResource,\n createSignal,\n on,\n onCleanup,\n} from 'solid-js'\nimport { createStore, reconcile, unwrap } from 'solid-js/store'\nimport { useQueryClientResolver } from './QueryClientProvider'\nimport { useIsRestoring } from './isRestoring'\nimport type { UseBaseQueryOptions } from './types'\nimport type { Accessor, Signal } from 'solid-js'\nimport type { QueryClient } from './QueryClient'\nimport type {\n Query,\n QueryKey,\n QueryObserver,\n QueryObserverResult,\n} from '@tanstack/query-core'\n\nfunction reconcileFn<TData, TError>(\n store: QueryObserverResult<TData, TError>,\n result: QueryObserverResult<TData, TError>,\n reconcileOption:\n | string\n | false\n | ((oldData: TData | undefined, newData: TData) => TData),\n queryHash?: string,\n): QueryObserverResult<TData, TError> {\n if (reconcileOption === false) return result\n if (typeof reconcileOption === 'function') {\n const newData = reconcileOption(store.data, result.data as TData)\n return { ...result, data: newData } as typeof result\n }\n let data = result.data\n if (store.data === undefined) {\n try {\n data = structuredClone(data)\n } catch (error) {\n if (process.env.NODE_ENV !== 'production') {\n if (error instanceof Error) {\n console.warn(\n `Unable to correctly reconcile data for query key: ${queryHash}. ` +\n `Possibly because the query data contains data structures that aren't supported ` +\n `by the 'structuredClone' algorithm. Consider using a callback function instead ` +\n `to manage the reconciliation manually.\\n\\n Error Received: ${error.name} - ${error.message}`,\n )\n }\n }\n }\n }\n const newData = reconcile(data, { key: reconcileOption })(store.data)\n return { ...result, data: newData } as typeof result\n}\n\n/**\n * Solid's `onHydrated` functionality will silently \"fail\" (hydrate with an empty object)\n * if the resource data is not serializable.\n */\nconst hydratableObserverResult = <\n TQueryFnData,\n TError,\n TData,\n TQueryKey extends QueryKey,\n TDataHydratable,\n>(\n query: Query<TQueryFnData, TError, TData, TQueryKey>,\n result: QueryObserverResult<TDataHydratable, TError>,\n) => {\n if (!isServer) return result\n const obj: any = {\n ...unwrap(result),\n // During SSR, functions cannot be serialized, so we need to remove them\n // This is safe because we will add these functions back when the query is hydrated\n refetch: undefined,\n }\n\n // If the query is an infinite query, we need to remove additional properties\n if ('fetchNextPage' in result) {\n obj.fetchNextPage = undefined\n obj.fetchPreviousPage = undefined\n }\n\n // We will also attach the dehydrated state of the query to the result\n // This will be removed on client after hydration\n obj.hydrationData = {\n state: query.state,\n queryKey: query.queryKey,\n queryHash: query.queryHash,\n ...(query.meta && { meta: query.meta }),\n }\n\n return obj\n}\n\n// Base Query Function that is used to create the query.\nexport function useBaseQuery<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey extends QueryKey,\n>(\n options: Accessor<\n UseBaseQueryOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey>\n >,\n Observer: typeof QueryObserver,\n queryClient?: Accessor<QueryClient>,\n) {\n type ResourceData = QueryObserverResult<TData, TError>\n\n const resolveClient = useQueryClientResolver(queryClient)\n const client = createMemo(() => resolveClient())\n const isRestoring = useIsRestoring()\n // There are times when we run a query on the server but the resource is never read\n // This could lead to times when the queryObserver is unsubscribed before the resource has loaded\n // Causing a time out error. To prevent this we will queue the unsubscribe if the cleanup is called\n // before the resource has loaded\n let unsubscribeQueued = false\n\n const defaultedOptions = createMemo(() => {\n const defaultOptions = client().defaultQueryOptions(options())\n defaultOptions._optimisticResults = isRestoring()\n ? 'isRestoring'\n : 'optimistic'\n defaultOptions.structuralSharing = false\n if (isServer) {\n defaultOptions.retry = false\n defaultOptions.throwOnError = true\n }\n return defaultOptions\n })\n const initialOptions = defaultedOptions()\n\n const [observer, setObserver] = createSignal(\n new Observer(client(), defaultedOptions()),\n )\n\n let observerResult = observer().getOptimisticResult(defaultedOptions())\n const [state, setState] =\n createStore<QueryObserverResult<TData, TError>>(observerResult)\n\n const createServerSubscriber = (\n resolve: (\n data: ResourceData | PromiseLike<ResourceData | undefined> | undefined,\n ) => void,\n reject: (reason?: any) => void,\n ) => {\n return observer().subscribe((result) => {\n notifyManager.batchCalls(() => {\n const query = observer().getCurrentQuery()\n const unwrappedResult = hydratableObserverResult(query, result)\n\n if (result.data !== undefined && unwrappedResult.isError) {\n reject(unwrappedResult.error)\n unsubscribeIfQueued()\n } else {\n resolve(unwrappedResult)\n unsubscribeIfQueued()\n }\n })()\n })\n }\n\n const unsubscribeIfQueued = () => {\n if (unsubscribeQueued) {\n unsubscribe?.()\n unsubscribeQueued = false\n }\n }\n\n const createClientSubscriber = () => {\n const obs = observer()\n return obs.subscribe((result) => {\n observerResult = result\n queueMicrotask(() => {\n if (unsubscribe) {\n refetch()\n }\n })\n })\n }\n\n function setStateWithReconciliation(res: typeof observerResult) {\n const opts = observer().options\n // @ts-expect-error - Reconcile option is not correctly typed internally\n const reconcileOptions = opts.reconcile\n\n setState((store) => {\n return reconcileFn(\n store,\n res,\n reconcileOptions === undefined ? false : reconcileOptions,\n opts.queryHash,\n )\n })\n }\n\n function createDeepSignal<T>(): Signal<T> {\n return [\n () => state,\n (v: any) => {\n const unwrapped = unwrap(state)\n if (typeof v === 'function') {\n v = v(unwrapped)\n }\n // Hydration data exists on first load after SSR,\n // and should be removed from the observer result\n if (v?.hydrationData) {\n const { hydrationData, ...rest } = v\n v = rest\n }\n setStateWithReconciliation(v)\n },\n ] as Signal<T>\n }\n\n /**\n * Unsubscribe is set lazily, so that we can subscribe after hydration when needed.\n */\n let unsubscribe: (() => void) | null = null\n\n /*\n Fixes #7275\n In a few cases, the observer could unmount before the resource is loaded.\n This leads to Suspense boundaries to be suspended indefinitely.\n This resolver will be called when the observer is unmounting\n but the resource is still in a loading state\n */\n let resolver: ((value: ResourceData) => void) | null = null\n const [queryResource, { refetch }] = createResource<ResourceData | undefined>(\n () => {\n const obs = observer()\n return new Promise((resolve, reject) => {\n resolver = resolve\n if (isServer) {\n unsubscribe = createServerSubscriber(resolve, reject)\n } else if (!unsubscribe && !isRestoring()) {\n unsubscribe = createClientSubscriber()\n }\n obs.updateResult()\n\n if (\n observerResult.isError &&\n !observerResult.isFetching &&\n !isRestoring() &&\n shouldThrowError(obs.options.throwOnError, [\n observerResult.error,\n obs.getCurrentQuery(),\n ])\n ) {\n setStateWithReconciliation(observerResult)\n return reject(observerResult.error)\n }\n if (!observerResult.isLoading) {\n resolver = null\n return resolve(\n hydratableObserverResult(obs.getCurrentQuery(), observerResult),\n )\n }\n\n setStateWithReconciliation(observerResult)\n })\n },\n {\n storage: createDeepSignal,\n\n get deferStream() {\n return options().deferStream\n },\n\n /**\n * If this resource was populated on the server (either sync render, or streamed in over time), onHydrated\n * will be called. This is the point at which we can hydrate the query cache state, and setup the query subscriber.\n *\n * Leveraging onHydrated allows us to plug into the async and streaming support that solidjs resources already support.\n *\n * Note that this is only invoked on the client, for queries that were originally run on the server.\n */\n onHydrated(_k, info) {\n if (info.value && 'hydrationData' in info.value) {\n hydrate(client(), {\n // @ts-expect-error - hydrationData is not correctly typed internally\n queries: [{ ...info.value.hydrationData }],\n })\n }\n\n if (unsubscribe) return\n /**\n * Do not refetch query on mount if query was fetched on server,\n * even if `staleTime` is not set.\n */\n const newOptions = { ...initialOptions }\n if (\n (initialOptions.staleTime || !initialOptions.initialData) &&\n info.value\n ) {\n newOptions.refetchOnMount = false\n }\n // Setting the options as an immutable object to prevent\n // wonky behavior with observer subscriptions\n observer().setOptions(newOptions)\n setStateWithReconciliation(observer().getOptimisticResult(newOptions))\n unsubscribe = createClientSubscriber()\n },\n },\n )\n\n createComputed(\n on(\n client,\n (c) => {\n if (unsubscribe) {\n unsubscribe()\n }\n const newObserver = new Observer(c, defaultedOptions())\n unsubscribe = createClientSubscriber()\n setObserver(newObserver)\n },\n {\n defer: true,\n },\n ),\n )\n\n createComputed(\n on(\n isRestoring,\n (restoring) => {\n if (!restoring && !isServer) {\n refetch()\n }\n },\n { defer: true },\n ),\n )\n\n onCleanup(() => {\n if (isServer && queryResource.loading) {\n unsubscribeQueued = true\n return\n }\n if (unsubscribe) {\n unsubscribe()\n unsubscribe = null\n }\n if (resolver && !isServer) {\n resolver(observerResult)\n resolver = null\n }\n })\n\n createComputed(\n on(\n [observer, defaultedOptions],\n ([obs, opts]) => {\n obs.setOptions(opts)\n setStateWithReconciliation(obs.getOptimisticResult(opts))\n refetch()\n },\n { defer: true },\n ),\n )\n\n const handler = {\n get(\n target: QueryObserverResult<TData, TError>,\n prop: keyof QueryObserverResult<TData, TError>,\n ): any {\n if (prop === 'data') {\n if (state.data !== undefined) {\n return queryResource.latest?.data\n }\n return queryResource()?.data\n }\n return Reflect.get(target, prop)\n },\n }\n\n return new Proxy(state, handler)\n}\n","import { QueryObserver } from '@tanstack/query-core'\nimport { createMemo } from 'solid-js'\nimport { useBaseQuery } from './useBaseQuery'\nimport type { DefaultError, QueryKey } from '@tanstack/query-core'\nimport type { QueryClient } from './QueryClient'\nimport type { Accessor } from 'solid-js'\nimport type {\n DefinedUseQueryResult,\n UseQueryOptions,\n UseQueryResult,\n} from './types'\nimport type {\n DefinedInitialDataOptions,\n UndefinedInitialDataOptions,\n} from './queryOptions'\n\n/**\n * Subscribes to a query: a declarative dependency on an asynchronous source of data that is tied to a unique key.\n * The query runs when the options call for it — `enabled: false` skips the initial fetch.\n *\n * @see {@link queryOptions} to share these options between `useQuery` and imperative APIs like `queryClient.query`.\n * @param options - An accessor returning the {@link UndefinedInitialDataOptions} to use — everything you can\n * pass to `useQuery`.\n * @param queryClient - An accessor for a custom `QueryClient`. Otherwise, the one from the nearest context\n * will be used.\n * @returns The current query result, as a Solid store. `status` is `pending` if there is no cached data to\n * display, `error` if the last fetch attempt failed, or `success` if the query has data to display.\n * `isPending`/`isSuccess`/`isError` are derived booleans for convenience.\n *\n * @example\n * ```tsx\n * import { For, Match, Switch } from 'solid-js'\n * import { useQuery } from '@tanstack/solid-query'\n *\n * function Posts() {\n * const postsQuery = useQuery(() => ({\n * queryKey: ['posts'],\n * queryFn: fetchPosts,\n * }))\n *\n * return (\n * <Switch>\n * <Match when={postsQuery.isPending}>Loading...</Match>\n * <Match when={postsQuery.isError}>Error: {postsQuery.error.message}</Match>\n * <Match when={postsQuery.isSuccess}>\n * <ul>\n * <For each={postsQuery.data}>{(post) => <li>{post.title}</li>}</For>\n * </ul>\n * <div>{postsQuery.isFetching ? 'Background Updating...' : ' '}</div>\n * </Match>\n * </Switch>\n * )\n * }\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 * ```tsx\n * import { Match, Switch } from 'solid-js'\n * import { useQuery } from '@tanstack/solid-query'\n *\n * function PostCount() {\n * const postsQuery = useQuery(() => ({\n * queryKey: ['posts'],\n * queryFn: fetchPosts,\n * select: (posts) => posts.length,\n * }))\n *\n * return (\n * <Switch>\n * <Match when={postsQuery.isPending}>Loading...</Match>\n * <Match when={postsQuery.isError}>Error: {postsQuery.error.message}</Match>\n * <Match when={postsQuery.isSuccess}>{postsQuery.data} posts</Match>\n * </Switch>\n * )\n * }\n * ```\n *\n * @example\n * A dependent query, only enabled once `postId` is set:\n * ```tsx\n * import { Match, Switch } from 'solid-js'\n * import { useQuery } from '@tanstack/solid-query'\n *\n * function Post(props: { postId: number | undefined }) {\n * const postQuery = useQuery(() => ({\n * queryKey: ['post', props.postId],\n * queryFn: () => fetchPost(props.postId!),\n * enabled: props.postId != null,\n * }))\n *\n * return (\n * <Switch fallback={<h1>{postQuery.data?.title}</h1>}>\n * <Match when={props.postId == null}>Select a post</Match>\n * <Match when={postQuery.isLoading}>Loading...</Match>\n * <Match when={postQuery.isError}>Error: {postQuery.error.message}</Match>\n * </Switch>\n * )\n * }\n * ```\n *\n * @example\n * The same dependent query, using `skipToken` to disable it in a type-safe way instead of relying on\n * `enabled`. The non-null assertion is still needed — Solid's `props` narrowing doesn't survive into the\n * `queryFn` closure the way a local `const` would — but `skipToken` keeps `queryFn`'s return type accurate\n * without it. `refetch` doesn't work while `queryFn` is `skipToken` — use `enabled: false` instead if you\n * need to trigger the query manually:\n * ```tsx\n * import { Match, Switch } from 'solid-js'\n * import { skipToken, useQuery } from '@tanstack/solid-query'\n *\n * function Post(props: { postId: number | undefined }) {\n * const postQuery = useQuery(() => ({\n * queryKey: ['post', props.postId],\n * queryFn: props.postId != null ? () => fetchPost(props.postId!) : skipToken,\n * }))\n *\n * return (\n * <Switch fallback={<h1>{postQuery.data?.title}</h1>}>\n * <Match when={props.postId == null}>Select a post</Match>\n * <Match when={postQuery.isLoading}>Loading...</Match>\n * <Match when={postQuery.isError}>Error: {postQuery.error.message}</Match>\n * </Switch>\n * )\n * }\n * ```\n *\n * @example\n * Seeding a detail query from an already-cached list, to skip the loading state:\n * ```tsx\n * import { useQuery, useQueryClient } from '@tanstack/solid-query'\n *\n * function Post(props: { postId: number }) {\n * const queryClient = useQueryClient()\n *\n * const postQuery = 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 *\n * return postQuery.isError ? <span>Error: {postQuery.error.message}</span> : <h1>{postQuery.data?.title}</h1>\n * }\n * ```\n *\n * @example\n * Paginated data, keeping the previous page's data visible while the next page loads:\n * ```tsx\n * import { For, createSignal } from 'solid-js'\n * import { keepPreviousData, useQuery } from '@tanstack/solid-query'\n *\n * function Posts() {\n * const [page, setPage] = createSignal(0)\n *\n * const postsQuery = useQuery(() => ({\n * queryKey: ['posts', page()],\n * queryFn: () => fetchPosts(page()),\n * placeholderData: keepPreviousData,\n * }))\n *\n * return (\n * <div>\n * <ul>\n * <For each={postsQuery.data}>{(post) => <li>{post.title}</li>}</For>\n * </ul>\n * <button\n * disabled={postsQuery.isPlaceholderData}\n * onClick={() => setPage((old) => old + 1)}\n * >\n * Next Page\n * </button>\n * </div>\n * )\n * }\n * ```\n */\nexport function useQuery<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: UndefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>,\n queryClient?: () => QueryClient,\n): UseQueryResult<TData, TError>\n\n/**\n * Subscribes to a query: a declarative dependency on an asynchronous source of data that is tied to a unique key.\n * The query runs when the options call for it — `enabled: false` skips the initial fetch.\n *\n * This overload is selected when `initialData` is set, so the resulting `data` is never `undefined`.\n *\n * @see {@link queryOptions} to share these options between `useQuery` and imperative APIs like `queryClient.query`.\n * @param options - An accessor returning the {@link DefinedInitialDataOptions} to use — everything you can\n * pass to `useQuery`, with `initialData` set.\n * @param queryClient - An accessor for a custom `QueryClient`. Otherwise, the one from the nearest context\n * will be used.\n * @returns The current query result, as a Solid store, typed so that `status` is `success` — or `error` if a\n * fetch attempt fails while keeping the existing data (`status` never resolves to `pending` in this overload's\n * type, since `initialData` guarantees data upfront). `isSuccess`/`isError` are derived booleans for\n * convenience.\n *\n * @example\n * ```tsx\n * import { For } from 'solid-js'\n * import { useQuery } from '@tanstack/solid-query'\n *\n * function Posts() {\n * // `postsQuery.data` is never `undefined`, thanks to `initialData` — even if a refetch fails, so the\n * // list stays visible alongside the error.\n * const postsQuery = useQuery(() => ({\n * queryKey: ['posts'],\n * queryFn: fetchPosts,\n * initialData: [],\n * }))\n *\n * return (\n * <div>\n * {postsQuery.isError ? <span>Error: {postsQuery.error.message}</span> : null}\n * <ul>\n * <For each={postsQuery.data}>{(post) => <li>{post.title}</li>}</For>\n * </ul>\n * </div>\n * )\n * }\n * ```\n */\nexport function useQuery<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: DefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>,\n queryClient?: () => QueryClient,\n): DefinedUseQueryResult<TData, TError>\nexport function useQuery<\n TQueryFnData,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>,\n queryClient?: Accessor<QueryClient>,\n) {\n return useBaseQuery(\n createMemo(() => options()),\n QueryObserver,\n queryClient,\n )\n}\n","import { InfiniteQueryObserver } from '@tanstack/query-core'\nimport { createMemo } from 'solid-js'\nimport { useBaseQuery } from './useBaseQuery'\nimport type {\n DefaultError,\n InfiniteData,\n QueryKey,\n QueryObserver,\n} from '@tanstack/query-core'\nimport type { QueryClient } from './QueryClient'\nimport type {\n DefinedUseInfiniteQueryResult,\n UseInfiniteQueryOptions,\n UseInfiniteQueryResult,\n} from './types'\nimport type { Accessor } from 'solid-js'\nimport type {\n DefinedInitialDataInfiniteOptions,\n UndefinedInitialDataInfiniteOptions,\n} from './infiniteQueryOptions'\n\n/**\n * The options for `useInfiniteQuery` are identical to `useQuery`, with the addition of\n * `initialPageParam`, `getNextPageParam`, `getPreviousPageParam`, and `maxPages`.\n *\n * This overload is selected when `initialData` is set.\n *\n * @remarks Keep in mind that imperative fetch calls, such as `fetchNextPage`, may interfere with the default\n * refetch behavior, resulting in outdated data. Make sure to call these functions only in response to user\n * actions, or add conditions like `hasNextPage && !isFetching`.\n * @see {@link infiniteQueryOptions} to share these options between `useInfiniteQuery` and imperative APIs like `queryClient.infiniteQuery`.\n * @param options - An accessor returning the {@link DefinedInitialDataInfiniteOptions} to use — everything you\n * can pass to `useInfiniteQuery`, with `initialData` set.\n * @param queryClient - An accessor for a custom `QueryClient`. Otherwise, the one from the nearest context\n * will be used.\n * @returns The same properties as `useQuery`, with the addition of `fetchNextPage`, `fetchPreviousPage`,\n * `hasNextPage`, `hasPreviousPage`, `isFetchingNextPage`, and `isFetchingPreviousPage`. `data.pages` and\n * `data.pageParams` are also added, as long as a `select` doesn't change `TData` away from its default\n * `InfiniteData<TQueryFnData>` shape.\n *\n * @example\n * ```tsx\n * import { For } from 'solid-js'\n * import { useInfiniteQuery } from '@tanstack/solid-query'\n *\n * function Projects() {\n * // `projectsQuery.data` is never `undefined`, thanks to `initialData` — even if a refetch fails, so the\n * // list stays visible alongside the error.\n * const projectsQuery = useInfiniteQuery(() => ({\n * queryKey: ['projects'],\n * queryFn: ({ pageParam }) => fetchProjects(pageParam),\n * initialPageParam: 0,\n * getNextPageParam: (lastPage) => lastPage.nextId,\n * initialData: { pages: [], pageParams: [] },\n * }))\n *\n * return (\n * <div>\n * {projectsQuery.isError ? <span>Error: {projectsQuery.error.message}</span> : null}\n * <ul>\n * <For each={projectsQuery.data.pages}>\n * {(page) => <For each={page.projects}>{(p) => <li>{p.name}</li>}</For>}\n * </For>\n * </ul>\n * </div>\n * )\n * }\n * ```\n */\nexport function useInfiniteQuery<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: DefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n queryClient?: Accessor<QueryClient>,\n): DefinedUseInfiniteQueryResult<TData, TError>\n\n/**\n * The options for `useInfiniteQuery` are identical to `useQuery`, with the addition of\n * `initialPageParam`, `getNextPageParam`, `getPreviousPageParam`, and `maxPages`.\n *\n * @remarks Keep in mind that imperative fetch calls, such as `fetchNextPage`, may interfere with the default\n * refetch behavior, resulting in outdated data. Make sure to call these functions only in response to user\n * actions, or add conditions like `hasNextPage && !isFetching`.\n * @see {@link infiniteQueryOptions} to share these options between `useInfiniteQuery` and imperative APIs like `queryClient.infiniteQuery`.\n * @param options - An accessor returning the {@link UndefinedInitialDataInfiniteOptions} to use — everything\n * you can pass to `useInfiniteQuery`.\n * @param queryClient - An accessor for a custom `QueryClient`. Otherwise, the one from the nearest context\n * will be used.\n * @returns The same properties as `useQuery`, with the addition of `fetchNextPage`, `fetchPreviousPage`,\n * `hasNextPage`, `hasPreviousPage`, `isFetchingNextPage`, and `isFetchingPreviousPage`. `data.pages` and\n * `data.pageParams` are also added, as long as a `select` doesn't change `TData` away from its default\n * `InfiniteData<TQueryFnData>` shape.\n *\n * @example\n * Fetching the next page from a \"Load More\" button click:\n * ```tsx\n * import { For, Match, Switch } from 'solid-js'\n * import { useInfiniteQuery } from '@tanstack/solid-query'\n *\n * function Projects() {\n * const projectsQuery = useInfiniteQuery(() => ({\n * queryKey: ['projects'],\n * queryFn: ({ pageParam }) => fetchProjects(pageParam),\n * initialPageParam: 0,\n * getNextPageParam: (lastPage) => lastPage.nextId,\n * }))\n *\n * return (\n * <Switch>\n * <Match when={projectsQuery.isPending}>Loading...</Match>\n * <Match when={projectsQuery.isError}>Error: {projectsQuery.error.message}</Match>\n * <Match when={projectsQuery.isSuccess}>\n * <ul>\n * <For each={projectsQuery.data.pages}>\n * {(page) => <For each={page.projects}>{(p) => <li>{p.name}</li>}</For>}\n * </For>\n * </ul>\n * <button\n * onClick={() => projectsQuery.fetchNextPage()}\n * disabled={!projectsQuery.hasNextPage || projectsQuery.isFetching}\n * >\n * {projectsQuery.isFetchingNextPage\n * ? 'Loading more...'\n * : projectsQuery.hasNextPage\n * ? 'Load More'\n * : 'Nothing more to load'}\n * </button>\n * </Match>\n * </Switch>\n * )\n * }\n * ```\n *\n * @example\n * Fetching the next page automatically as the user scrolls, using an `IntersectionObserver` on a\n * sentinel element after the list:\n * ```tsx\n * import { For, Match, Switch, createEffect, onCleanup } from 'solid-js'\n * import { useInfiniteQuery } from '@tanstack/solid-query'\n *\n * function Projects() {\n * const projectsQuery = useInfiniteQuery(() => ({\n * queryKey: ['projects'],\n * queryFn: ({ pageParam }) => fetchProjects(pageParam),\n * initialPageParam: 0,\n * getNextPageParam: (lastPage) => lastPage.nextId,\n * }))\n *\n * let sentinelRef: HTMLDivElement | undefined\n *\n * createEffect(() => {\n * if (sentinelRef == null || !projectsQuery.hasNextPage || projectsQuery.isFetching) return\n *\n * const observer = new IntersectionObserver(([entry]) => {\n * if (entry?.isIntersecting) projectsQuery.fetchNextPage()\n * })\n * observer.observe(sentinelRef)\n *\n * onCleanup(() => observer.disconnect())\n * })\n *\n * return (\n * <Switch>\n * <Match when={projectsQuery.isPending}>Loading...</Match>\n * <Match when={projectsQuery.isError}>Error: {projectsQuery.error.message}</Match>\n * <Match when={projectsQuery.isSuccess}>\n * <ul>\n * <For each={projectsQuery.data.pages}>\n * {(page) => <For each={page.projects}>{(p) => <li>{p.name}</li>}</For>}\n * </For>\n * </ul>\n * <div ref={sentinelRef}>{projectsQuery.isFetchingNextPage ? 'Loading more...' : null}</div>\n * </Match>\n * </Switch>\n * )\n * }\n * ```\n */\nexport function useInfiniteQuery<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: UndefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n queryClient?: Accessor<QueryClient>,\n): UseInfiniteQueryResult<TData, TError>\n\nexport function useInfiniteQuery<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: UseInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n queryClient?: Accessor<QueryClient>,\n): UseInfiniteQueryResult<TData, TError> {\n return useBaseQuery(\n createMemo(() => options()),\n InfiniteQueryObserver as typeof QueryObserver,\n queryClient,\n ) as UseInfiniteQueryResult<TData, TError>\n}\n","import { MutationObserver, noop, shouldThrowError } from '@tanstack/query-core'\nimport { createComputed, createMemo, on, onCleanup } from 'solid-js'\nimport { createStore } from 'solid-js/store'\nimport { useQueryClientResolver } from './QueryClientProvider'\nimport type { DefaultError } from '@tanstack/query-core'\nimport type { QueryClient } from './QueryClient'\nimport type {\n UseMutateFunction,\n UseMutationOptions,\n UseMutationResult,\n} from './types'\nimport type { Accessor } from 'solid-js'\n\n/**\n * Unlike queries, mutations are typically used to create/update/delete data or perform server side-effects.\n * `useMutation` is the primitive for that.\n *\n * @param options - An accessor returning the {@link UseMutationOptions} to use.\n * @param queryClient - An accessor for a custom `QueryClient`. Otherwise, the one from the nearest context\n * will be used.\n * @returns `mutate`/`mutateAsync` also accept per-call `onSuccess`/`onError`/`onSettled` callbacks as a second\n * argument, useful for triggering call-site side effects (e.g. navigation) without coupling them to the shared\n * mutation definition. Hook-level callbacks (passed to `options`) fire for every mutation; per-call callbacks\n * fire only for the latest call you've made, and only while the component is still mounted — unmounting before\n * the mutation settles removes the subscription and prevents them from firing.\n *\n * @example\n * ```tsx\n * import { useMutation, useQueryClient } from '@tanstack/solid-query'\n *\n * function TodoItem(props: { id: number }) {\n * const queryClient = useQueryClient()\n *\n * const deleteTodoMutation = useMutation(() => ({\n * mutationFn: deleteTodo,\n * onSuccess: () => {\n * queryClient.invalidateQueries({ queryKey: ['todos'] })\n * },\n * }))\n *\n * return (\n * <button onClick={() => deleteTodoMutation.mutate({ id: props.id })} disabled={deleteTodoMutation.isPending}>\n * Delete\n * </button>\n * )\n * }\n * ```\n *\n * @example\n * Rendering the mutation's own state, rather than just firing it off:\n * ```tsx\n * import { Match, Switch } from 'solid-js'\n * import { useMutation, useQueryClient } from '@tanstack/solid-query'\n *\n * function AddTodo() {\n * const queryClient = useQueryClient()\n *\n * const addMutation = useMutation(() => ({\n * mutationFn: addTodo,\n * onSuccess: () => queryClient.invalidateQueries({ queryKey: ['todos'] }),\n * }))\n *\n * return (\n * <Switch fallback={<button onClick={() => addMutation.mutate('Item')}>Add</button>}>\n * <Match when={addMutation.isPending}>Adding todo...</Match>\n * <Match when={addMutation.isError}>\n * <div>An error occurred: {addMutation.error?.message}</div>\n * <button onClick={() => addMutation.mutate('Item')}>Add</button>\n * </Match>\n * </Switch>\n * )\n * }\n * ```\n *\n * @example\n * Optimistic update via `onMutate`, rolling back on `onError`:\n * ```tsx\n * import { useMutation, useQueryClient } from '@tanstack/solid-query'\n *\n * function AddTodo() {\n * const queryClient = useQueryClient()\n *\n * const addMutation = useMutation(() => ({\n * mutationFn: addTodo,\n * onMutate: async (newTodo) => {\n * await queryClient.cancelQueries({ queryKey: ['todos'] })\n * const previousTodos = queryClient.getQueryData<Array<string>>(['todos'])\n *\n * queryClient.setQueryData<Array<string>>(['todos'], (old) => [\n * ...(old ?? []),\n * newTodo,\n * ])\n *\n * // Passed to `onError` as `onMutateResult` if the mutation fails.\n * return { previousTodos }\n * },\n * onError: (_err, _newTodo, onMutateResult) => {\n * queryClient.setQueryData(['todos'], onMutateResult?.previousTodos)\n * },\n * onSettled: () => {\n * queryClient.invalidateQueries({ queryKey: ['todos'] })\n * },\n * }))\n *\n * return (\n * <button onClick={() => addMutation.mutate('Item')}>Add</button>\n * )\n * }\n * ```\n *\n * @example\n * Callbacks passed per call to `mutate` only fire for the last call — `mutateAsync` gives you a\n * promise per call instead, so you can wait for all of them when they succeed:\n * ```tsx\n * import { useMutation, useQueryClient } from '@tanstack/solid-query'\n *\n * function AddTodos() {\n * const queryClient = useQueryClient()\n *\n * const addMutation = useMutation(() => ({\n * mutationFn: addTodo,\n * onSuccess: () => queryClient.invalidateQueries({ queryKey: ['todos'] }),\n * }))\n *\n * async function handleAddAll(todos: Array<string>) {\n * try {\n * await Promise.all(todos.map((todo) => addMutation.mutateAsync(todo)))\n * } catch (error) {\n * console.error('Failed to add todos:', error)\n * }\n * }\n *\n * return (\n * <button onClick={() => handleAddAll(['Todo 1', 'Todo 2', 'Todo 3'])}>\n * Add all\n * </button>\n * )\n * }\n * ```\n *\n * @example\n * If some of the mutations above can fail independently of the others, and you want to know which ones\n * did — rather than losing that information the moment the first one rejects — swap `Promise.all` for\n * `Promise.allSettled`:\n * ```tsx\n * import { useMutation, useQueryClient } from '@tanstack/solid-query'\n *\n * function AddTodos() {\n * const queryClient = useQueryClient()\n *\n * const addMutation = useMutation(() => ({\n * mutationFn: addTodo,\n * onSuccess: () => queryClient.invalidateQueries({ queryKey: ['todos'] }),\n * }))\n *\n * async function handleAddAll(todos: Array<string>) {\n * const addResults = await Promise.allSettled(\n * todos.map((todo) => addMutation.mutateAsync(todo)),\n * )\n *\n * addResults.forEach((addResult, index) => {\n * if (addResult.status === 'rejected') {\n * console.error(`Failed to add \"${todos[index]}\":`, addResult.reason)\n * }\n * })\n * }\n *\n * return (\n * <button onClick={() => handleAddAll(['Todo 1', 'Todo 2', 'Todo 3'])}>\n * Add all\n * </button>\n * )\n * }\n * ```\n */\nexport function useMutation<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TOnMutateResult = unknown,\n>(\n options: UseMutationOptions<TData, TError, TVariables, TOnMutateResult>,\n queryClient?: Accessor<QueryClient>,\n): UseMutationResult<TData, TError, TVariables, TOnMutateResult> {\n const resolveClient = useQueryClientResolver(queryClient)\n const client = createMemo(() => resolveClient())\n\n const observer = new MutationObserver<\n TData,\n TError,\n TVariables,\n TOnMutateResult\n >(client(), options())\n\n const mutate: UseMutateFunction<\n TData,\n TError,\n TVariables,\n TOnMutateResult\n > = (...args) => {\n observer.mutate(args[0] as TVariables, args[1]).catch(noop)\n }\n\n const [state, setState] = createStore<\n UseMutationResult<TData, TError, TVariables, TOnMutateResult>\n >({\n ...observer.getCurrentResult(),\n mutate,\n mutateAsync: observer.getCurrentResult().mutate,\n })\n\n createComputed(() => {\n observer.setOptions(options())\n })\n\n createComputed(\n on(\n () => state.status,\n () => {\n if (\n state.isError &&\n shouldThrowError(observer.options.throwOnError, [state.error])\n ) {\n throw state.error\n }\n },\n ),\n )\n\n const unsubscribe = observer.subscribe((result) => {\n setState({\n ...result,\n mutate,\n mutateAsync: result.mutate,\n })\n })\n\n onCleanup(unsubscribe)\n\n return state\n}\n","import { QueriesObserver, noop } from '@tanstack/query-core'\nimport { createStore, unwrap } from 'solid-js/store'\nimport {\n batch,\n createComputed,\n createMemo,\n createRenderEffect,\n createResource,\n mergeProps,\n on,\n onCleanup,\n onMount,\n} from 'solid-js'\nimport { useQueryClientResolver } from './QueryClientProvider'\nimport { useIsRestoring } from './isRestoring'\nimport type { QueryOptions, UseQueryResult } from './types'\nimport type { Accessor } from 'solid-js'\nimport type { QueryClient } from './QueryClient'\nimport type {\n DefaultError,\n OmitKeyof,\n QueriesObserverOptions,\n QueriesPlaceholderDataFunction,\n QueryFunction,\n QueryKey,\n QueryObserverOptions,\n QueryObserverResult,\n ThrowOnError,\n} from '@tanstack/query-core'\n\n// This defines the `UseQueryOptions` that are accepted in `QueriesOptions` & `GetOptions`.\n// `placeholderData` function does not have a parameter\ntype UseQueryOptionsForUseQueries<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> = OmitKeyof<\n QueryOptions<TQueryFnData, TError, TData, TQueryKey>,\n 'placeholderData' | 'suspense'\n> & {\n placeholderData?: TQueryFnData | QueriesPlaceholderDataFunction<TQueryFnData>\n /**\n * @deprecated The `suspense` option has been deprecated in v5 and will be removed in the next major version.\n * The `data` property on useQueries is a plain object and not a SolidJS Resource.\n * It will not suspend when the data is loading.\n * Setting `suspense` to `true` will be a no-op.\n */\n suspense?: boolean\n}\n\n// Avoid TS depth-limit error in case of large array literal\ntype MAXIMUM_DEPTH = 20\n\n// Widen the type of the symbol to enable type inference even if skipToken is not immutable.\ntype SkipTokenForUseQueries = symbol\n\ntype GetOptions<T> =\n // Part 1: responsible for applying explicit type parameter to function arguments, if object { queryFnData: TQueryFnData, error: TError, data: TData }\n T extends {\n queryFnData: infer TQueryFnData\n error?: infer TError\n data: infer TData\n }\n ? UseQueryOptionsForUseQueries<TQueryFnData, TError, TData>\n : T extends { queryFnData: infer TQueryFnData; error?: infer TError }\n ? UseQueryOptionsForUseQueries<TQueryFnData, TError>\n : T extends { data: infer TData; error?: infer TError }\n ? UseQueryOptionsForUseQueries<unknown, TError, TData>\n : // Part 2: responsible for applying explicit type parameter to function arguments, if tuple [TQueryFnData, TError, TData]\n T extends [infer TQueryFnData, infer TError, infer TData]\n ? UseQueryOptionsForUseQueries<TQueryFnData, TError, TData>\n : T extends [infer TQueryFnData, infer TError]\n ? UseQueryOptionsForUseQueries<TQueryFnData, TError>\n : T extends [infer TQueryFnData]\n ? UseQueryOptionsForUseQueries<TQueryFnData>\n : // Part 3: responsible for inferring and enforcing type if no explicit parameter was provided\n T extends {\n queryFn?:\n | QueryFunction<infer TQueryFnData, infer TQueryKey>\n | SkipTokenForUseQueries\n select?: (data: any) => infer TData\n throwOnError?: ThrowOnError<any, infer TError, any, any>\n }\n ? UseQueryOptionsForUseQueries<\n TQueryFnData,\n unknown extends TError ? DefaultError : TError,\n unknown extends TData ? TQueryFnData : TData,\n TQueryKey\n >\n : // Fallback\n UseQueryOptionsForUseQueries\n\ntype GetResults<T> =\n // Part 1: responsible for mapping explicit type parameter to function result, if object\n T extends { queryFnData: any; error?: infer TError; data: infer TData }\n ? UseQueryResult<TData, TError>\n : T extends { queryFnData: infer TQueryFnData; error?: infer TError }\n ? UseQueryResult<TQueryFnData, TError>\n : T extends { data: infer TData; error?: infer TError }\n ? UseQueryResult<TData, TError>\n : // Part 2: responsible for mapping explicit type parameter to function result, if tuple\n T extends [any, infer TError, infer TData]\n ? UseQueryResult<TData, TError>\n : T extends [infer TQueryFnData, infer TError]\n ? UseQueryResult<TQueryFnData, TError>\n : T extends [infer TQueryFnData]\n ? UseQueryResult<TQueryFnData>\n : // Part 3: responsible for mapping inferred type to results, if no explicit parameter was provided\n T extends {\n queryFn?:\n | QueryFunction<infer TQueryFnData, any>\n | SkipTokenForUseQueries\n select?: (data: any) => infer TData\n throwOnError?: ThrowOnError<any, infer TError, any, any>\n }\n ? UseQueryResult<\n unknown extends TData ? TQueryFnData : TData,\n unknown extends TError ? DefaultError : TError\n >\n : // Fallback\n UseQueryResult\n\n/**\n * QueriesOptions reducer recursively unwraps function arguments to infer/enforce type param\n */\ntype QueriesOptions<\n T extends Array<any>,\n TResult extends Array<any> = [],\n TDepth extends ReadonlyArray<number> = [],\n> = TDepth['length'] extends MAXIMUM_DEPTH\n ? Array<UseQueryOptionsForUseQueries>\n : T extends []\n ? []\n : T extends [infer Head]\n ? [...TResult, GetOptions<Head>]\n : T extends [infer Head, ...infer Tail]\n ? QueriesOptions<\n [...Tail],\n [...TResult, GetOptions<Head>],\n [...TDepth, 1]\n >\n : ReadonlyArray<unknown> extends T\n ? T\n : // If T is *some* array but we couldn't assign unknown[] to it, then it must hold some known/homogeneous type!\n // use this to infer the param types in the case of Array.map() argument\n T extends Array<\n UseQueryOptionsForUseQueries<\n infer TQueryFnData,\n infer TError,\n infer TData,\n infer TQueryKey\n >\n >\n ? Array<\n UseQueryOptionsForUseQueries<\n TQueryFnData,\n TError,\n TData,\n TQueryKey\n >\n >\n : // Fallback\n Array<UseQueryOptionsForUseQueries>\n\n/**\n * QueriesResults reducer recursively maps type param to results\n */\ntype QueriesResults<\n T extends Array<any>,\n TResult extends Array<any> = [],\n TDepth extends ReadonlyArray<number> = [],\n> = TDepth['length'] extends MAXIMUM_DEPTH\n ? Array<UseQueryResult>\n : T extends []\n ? []\n : T extends [infer Head]\n ? [...TResult, GetResults<Head>]\n : T extends [infer Head, ...infer Tail]\n ? QueriesResults<\n [...Tail],\n [...TResult, GetResults<Head>],\n [...TDepth, 1]\n >\n : { [K in keyof T]: GetResults<T[K]> }\n\n/**\n * The `useQueries` primitive can be used to fetch a variable number of queries.\n *\n * The `queries` key accepts an array with query option objects mostly identical to `useQuery` — see\n * `placeholderData` below for the one difference. A custom `QueryClient` is supplied once, as `useQueries`'\n * own top-level second argument, rather than per query.\n *\n * Having the same query key more than once in the array of query objects may cause some data to be shared\n * between queries. To avoid this, consider de-duplicating the queries and map the results back to the desired\n * structure.\n *\n * The `combine` option can be used to combine the results of the queries into a single value. The result will\n * be structurally shared to be as referentially stable as possible.\n *\n * `placeholderData` is supported here too, but unlike `useQuery`, it doesn't receive information from\n * previously rendered queries, because the number of queries can differ between renders.\n * @param queriesOptions - An accessor returning the `queries` array to run, and an optional `combine`\n * function.\n * @param queryClient - An accessor for a custom `QueryClient`. Otherwise, the one from the nearest context\n * will be used.\n * @returns The combined result. Without `combine`, this is an array with all the query results, in the same\n * order as the input. When `combine` is provided, this is the value returned by `combine` instead.\n *\n * @example\n * ```tsx\n * import { For } from 'solid-js'\n * import { useQueries } from '@tanstack/solid-query'\n *\n * function Posts(props: { ids: Array<number> }) {\n * const postQueries = useQueries(() => ({\n * queries: props.ids.map((id) => ({\n * queryKey: ['post', id],\n * queryFn: () => fetchPost(id),\n * staleTime: Infinity,\n * })),\n * }))\n *\n * return (\n * <ul>\n * <For each={postQueries}>\n * {(postQuery) => {\n * if (postQuery.isPending) return <li>Loading...</li>\n * if (postQuery.isError) return <li>Error: {postQuery.error.message}</li>\n * return <li>{postQuery.data.title}</li>\n * }}\n * </For>\n * </ul>\n * )\n * }\n * ```\n *\n * @example\n * Combining results into a single value:\n * ```tsx\n * import { For, Match, Switch } from 'solid-js'\n * import { useQueries } from '@tanstack/solid-query'\n *\n * function Posts(props: { ids: Array<number> }) {\n * const combinedPostsQuery = useQueries(() => ({\n * queries: props.ids.map((id) => ({\n * queryKey: ['post', id],\n * queryFn: () => fetchPost(id),\n * })),\n * combine: (postQueries) => {\n * return {\n * data: postQueries.map((postQuery) => postQuery.data),\n * isPending: postQueries.some((postQuery) => postQuery.isPending),\n * isError: postQueries.some((postQuery) => postQuery.isError),\n * }\n * },\n * }))\n *\n * return (\n * <Switch\n * fallback={\n * <ul>\n * <For each={combinedPostsQuery.data}>{(post) => <li>{post?.title}</li>}</For>\n * </ul>\n * }\n * >\n * <Match when={combinedPostsQuery.isPending}>Loading...</Match>\n * <Match when={combinedPostsQuery.isError}>Error loading posts</Match>\n * </Switch>\n * )\n * }\n * ```\n */\nexport function useQueries<\n T extends Array<any>,\n TCombinedResult extends QueriesResults<T> = QueriesResults<T>,\n>(\n queriesOptions: Accessor<{\n queries:\n | readonly [...QueriesOptions<T>]\n | readonly [...{ [K in keyof T]: GetOptions<T[K]> }]\n combine?: (result: QueriesResults<T>) => TCombinedResult\n }>,\n queryClient?: Accessor<QueryClient>,\n): TCombinedResult {\n const resolveClient = useQueryClientResolver(queryClient)\n const client = createMemo(() => resolveClient())\n const isRestoring = useIsRestoring()\n\n const defaultedQueries = createMemo(() =>\n queriesOptions().queries.map((options) =>\n mergeProps(\n client().defaultQueryOptions(options as QueryObserverOptions),\n {\n get _optimisticResults() {\n return isRestoring() ? 'isRestoring' : 'optimistic'\n },\n },\n ),\n ),\n )\n\n const observer = new QueriesObserver(\n client(),\n defaultedQueries(),\n queriesOptions().combine\n ? ({\n combine: queriesOptions().combine,\n } as QueriesObserverOptions<TCombinedResult>)\n : undefined,\n )\n\n const [state, setState] = createStore<TCombinedResult>(\n observer.getOptimisticResult(\n defaultedQueries(),\n (queriesOptions() as QueriesObserverOptions<TCombinedResult>).combine,\n )[1](),\n )\n\n createRenderEffect(\n on(\n () => queriesOptions().queries.length,\n () =>\n setState(\n observer.getOptimisticResult(\n defaultedQueries(),\n (queriesOptions() as QueriesObserverOptions<TCombinedResult>)\n .combine,\n )[1](),\n ),\n ),\n )\n\n const dataResources = createMemo(\n on(\n () => state.length,\n () =>\n state.map((queryRes) => {\n const dataPromise = () =>\n new Promise((resolve) => {\n if (queryRes.isFetching && queryRes.isLoading) return\n resolve(unwrap(queryRes.data))\n })\n return createResource(dataPromise)\n }),\n ),\n )\n\n batch(() => {\n const dataResources_ = dataResources()\n for (let index = 0; index < dataResources_.length; index++) {\n const dataResource = dataResources_[index]!\n dataResource[1].mutate(() => unwrap(state[index]!.data))\n dataResource[1].refetch()\n }\n })\n\n let taskQueue: Array<() => void> = []\n const subscribeToObserver = () =>\n observer.subscribe((result) => {\n taskQueue.push(() => {\n batch(() => {\n const dataResources_ = dataResources()\n for (let index = 0; index < dataResources_.length; index++) {\n const dataResource = dataResources_[index]!\n const unwrappedResult = { ...unwrap(result[index]) }\n // @ts-expect-error typescript pedantry regarding the possible range of index\n setState(index, unwrap(unwrappedResult))\n dataResource[1].mutate(() => unwrap(state[index]!.data))\n dataResource[1].refetch()\n }\n })\n })\n\n queueMicrotask(() => {\n const taskToRun = taskQueue.pop()\n if (taskToRun) taskToRun()\n taskQueue = []\n })\n })\n\n let unsubscribe: () => void = noop\n createComputed<() => void>((cleanup) => {\n cleanup?.()\n unsubscribe = isRestoring() ? noop : subscribeToObserver()\n // cleanup needs to be scheduled after synchronous effects take place\n return () => queueMicrotask(unsubscribe)\n })\n onCleanup(unsubscribe)\n\n onMount(() => {\n observer.setQueries(\n defaultedQueries(),\n queriesOptions().combine\n ? ({\n combine: queriesOptions().combine,\n } as QueriesObserverOptions<TCombinedResult>)\n : undefined,\n )\n })\n\n createComputed(() => {\n observer.setQueries(\n defaultedQueries(),\n queriesOptions().combine\n ? ({\n combine: queriesOptions().combine,\n } as QueriesObserverOptions<TCombinedResult>)\n : undefined,\n )\n })\n\n const handler = (index: number) => ({\n get(target: QueryObserverResult, prop: keyof QueryObserverResult): any {\n if (prop === 'data') {\n return dataResources()[index]![0]()\n }\n return Reflect.get(target, prop)\n },\n })\n\n const getProxies = () =>\n state.map((s, index) => {\n return new Proxy(s, handler(index))\n })\n\n const [proxyState, setProxyState] = createStore(getProxies())\n createRenderEffect(() => setProxyState(getProxies()))\n\n return proxyState as TCombinedResult\n}\n","import { QueryClient as QueryCoreClient } from '@tanstack/query-core'\nimport type {\n DefaultOptions as CoreDefaultOptions,\n DefaultError,\n OmitKeyof,\n QueryClientConfig as QueryCoreClientConfig,\n InfiniteQueryObserverOptions as QueryCoreInfiniteQueryObserverOptions,\n QueryObserverOptions as QueryCoreObserverOptions,\n QueryKey,\n} from '@tanstack/query-core'\n\n/**\n * The core `QueryObserverOptions`, with Solid's `reconcile` option added.\n *\n * @template TQueryFnData - The type your `queryFn` resolves to.\n * @template TError - The type of errors your `queryFn` may throw.\n * @template TData - The type `data` ends up as after `select` runs.\n * @template TQueryData - The type of the data actually held in the query cache.\n * @template TQueryKey - The type of your `queryKey`.\n * @template TPageParam - The type of the parameter passed to `queryFn` to fetch a given page, when this type\n * is shared with an infinite query's observer options. Defaults to `never` for regular queries.\n */\nexport interface QueryObserverOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = never,\n> extends OmitKeyof<\n QueryCoreObserverOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey,\n TPageParam\n >,\n 'structuralSharing'\n> {\n /**\n * Set this to a reconciliation key to enable reconciliation between query results.\n * Set this to `false` to disable reconciliation between query results.\n * Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom reconciliation logic.\n * Defaults reconciliation to false.\n */\n reconcile?:\n | string\n | false\n | ((oldData: TData | undefined, newData: TData) => TData)\n}\n\n/**\n * The core `InfiniteQueryObserverOptions`, with Solid's `reconcile` option added.\n *\n * @template TQueryFnData - The type of a single page, as your `queryFn` resolves it.\n * @template TError - The type of errors your `queryFn` may throw.\n * @template TData - The type `data` ends up as after `select` runs.\n * @template TQueryKey - The type of your `queryKey`.\n * @template TPageParam - The type of the parameter passed to `queryFn` to fetch a given page.\n */\nexport interface InfiniteQueryObserverOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n> extends OmitKeyof<\n QueryCoreInfiniteQueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n 'structuralSharing'\n> {\n /**\n * Set this to a reconciliation key to enable reconciliation between query results.\n * Set this to `false` to disable reconciliation between query results.\n * Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom reconciliation logic.\n * Defaults reconciliation to false.\n */\n reconcile?:\n | string\n | false\n | ((oldData: TData | undefined, newData: TData) => TData)\n}\n\n/**\n * The default options a `QueryClient` applies to every query, with Solid's `reconcile` option added to\n * `queries`.\n *\n * @template TError - The default type of errors thrown by queries and mutations using this `QueryClient`.\n */\nexport interface DefaultOptions<\n TError = DefaultError,\n> extends CoreDefaultOptions<TError> {\n queries?: OmitKeyof<QueryObserverOptions<unknown, TError>, 'queryKey'>\n}\n\n/**\n * The config accepted by `new QueryClient(config)`, with Solid's extended {@link DefaultOptions}.\n */\nexport interface QueryClientConfig extends QueryCoreClientConfig {\n defaultOptions?: DefaultOptions\n}\n\n/**\n * The core `@tanstack/query-core` `QueryClient`, typed so its `defaultOptions.queries` accepts Solid's\n * `reconcile` option.\n */\nexport class QueryClient extends QueryCoreClient {\n constructor(config: QueryClientConfig = {}) {\n super(config)\n }\n}\n","import type {\n DefaultError,\n QueryKey,\n QueryKeyWithDataTag,\n} from '@tanstack/query-core'\nimport type { QueryOptions } from './types'\nimport type { Accessor } from 'solid-js'\n\n/**\n * The options accepted by the `queryOptions` overload selected when no `initialData` is set — `data` may be\n * `undefined` while the query is `pending`. `queryOptions` itself accepts and returns a plain object (its\n * parameter type is `ReturnType<UndefinedInitialDataOptions<...>>`, i.e. this `Accessor` called); Solid's\n * reactivity applies where the result is consumed instead, e.g. `useQuery(() => options)`.\n *\n * @template TQueryFnData - The type your `queryFn` resolves to.\n * @template TError - The type of errors your `queryFn` may throw.\n * @template TData - The type `data` ends up as after `select` runs.\n * @template TQueryKey - The type of your `queryKey`.\n */\nexport type UndefinedInitialDataOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> = Accessor<\n QueryOptions<TQueryFnData, TError, TData, TQueryKey> & {\n initialData?: undefined\n }\n>\n\n/**\n * The options accepted by the `queryOptions` overload selected when `initialData` is set — `data` is never\n * `undefined`.\n *\n * @template TQueryFnData - The type your `queryFn` resolves to.\n * @template TError - The type of errors your `queryFn` may throw.\n * @template TData - The type `data` ends up as after `select` runs.\n * @template TQueryKey - The type of your `queryKey`.\n */\nexport type DefinedInitialDataOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> = Accessor<\n QueryOptions<TQueryFnData, TError, TData, TQueryKey> & {\n initialData: TQueryFnData | (() => TQueryFnData)\n }\n>\n\n/**\n * You can generally pass everything to `queryOptions` that you can also pass to `useQuery`. These options can\n * be shared across hooks and imperative APIs such as `queryClient.query`. `options.queryKey` is required and\n * is the query key to generate options for.\n *\n * This overload is selected when `initialData` is set, so the resulting `data` is never `undefined`.\n *\n * @see {@link useQuery} to run a query with these options.\n * @param options - The {@link DefinedInitialDataOptions} to use — everything you can pass to `useQuery`, with `initialData` set.\n * @returns The same options object, typed so that `queryKey` carries the inferred data type.\n *\n * @example\n * ```tsx\n * import { For } from 'solid-js'\n * import { queryOptions, useQuery } from '@tanstack/solid-query'\n *\n * const postsOptions = queryOptions({\n * queryKey: ['posts'],\n * queryFn: fetchPosts,\n * initialData: [],\n * })\n *\n * function Posts() {\n * // `postsQuery.data` is `Post[]`, never `undefined`, thanks to `initialData` — even if a refetch fails,\n * // so the list stays visible alongside the error.\n * const postsQuery = useQuery(() => postsOptions)\n *\n * return (\n * <div>\n * {postsQuery.isError ? <span>Error: {postsQuery.error.message}</span> : null}\n * <ul>\n * <For each={postsQuery.data}>{(post) => <li>{post.title}</li>}</For>\n * </ul>\n * </div>\n * )\n * }\n * ```\n */\nexport function queryOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: ReturnType<\n DefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>\n >,\n): ReturnType<\n DefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>\n> &\n QueryKeyWithDataTag<TQueryKey, TQueryFnData, TError>\n\n/**\n * You can generally pass everything to `queryOptions` that you can also pass to `useQuery`. These options can\n * be shared across hooks and imperative APIs such as `queryClient.query`. `options.queryKey` is required and\n * is the query key to generate options for.\n *\n * @see {@link useQuery} to run a query with these options.\n * @param options - The {@link UndefinedInitialDataOptions} to use — everything you can pass to `useQuery`.\n * @returns The same options object, typed so that `queryKey` carries the inferred data type.\n *\n * @example\n * A parameterized factory, so the same options object can be reused per `id`:\n * ```tsx\n * import { Match, Switch } from 'solid-js'\n * import { queryOptions, useQuery } from '@tanstack/solid-query'\n *\n * const postOptions = (id: string) =>\n * queryOptions({\n * queryKey: ['post', id],\n * queryFn: () => fetchPost(id),\n * })\n *\n * function Post(props: { id: string }) {\n * const postQuery = useQuery(() => postOptions(props.id))\n *\n * return (\n * <Switch>\n * <Match when={postQuery.isPending}>Loading...</Match>\n * <Match when={postQuery.isError}>Error: {postQuery.error.message}</Match>\n * <Match when={postQuery.isSuccess}>\n * <h1>{postQuery.data.title}</h1>\n * </Match>\n * </Switch>\n * )\n * }\n * ```\n */\nexport function queryOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: ReturnType<\n UndefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>\n >,\n): ReturnType<\n UndefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>\n> &\n QueryKeyWithDataTag<TQueryKey, TQueryFnData, TError>\n\nexport function queryOptions(options: unknown) {\n return options\n}\n","import { createEffect, createMemo, createSignal, onCleanup } from 'solid-js'\nimport { useQueryClientResolver } from './QueryClientProvider'\nimport type { QueryFilters } from '@tanstack/query-core'\nimport type { QueryClient } from './QueryClient'\nimport type { Accessor } from 'solid-js'\n\n/**\n * The `useIsFetching` primitive returns the `number` of the queries that your application is loading or fetching\n * in the background (useful for app-wide loading indicators).\n *\n * @param filters - An accessor returning the {@link QueryFilters} to narrow down the matched queries.\n * @param queryClient - An accessor for a custom `QueryClient`. Otherwise, the one from the nearest context\n * will be used.\n * @returns An accessor for the `number` of the queries that your application is currently loading or fetching\n * in the background.\n *\n * @example\n * ```tsx\n * import { useIsFetching } from '@tanstack/solid-query'\n *\n * function GlobalLoadingIndicator() {\n * // How many queries matching the posts prefix are fetching?\n * const isFetchingPosts = useIsFetching(() => ({ queryKey: ['posts'] }))\n *\n * return isFetchingPosts() > 0 ? <span>Loading posts...</span> : null\n * }\n * ```\n */\nexport function useIsFetching(\n filters?: Accessor<QueryFilters>,\n queryClient?: Accessor<QueryClient>,\n): Accessor<number> {\n const resolveClient = useQueryClientResolver(queryClient)\n const client = createMemo(() => resolveClient())\n const queryCache = createMemo(() => client().getQueryCache())\n\n const [fetches, setFetches] = createSignal(client().isFetching(filters?.()))\n\n createEffect(() => {\n setFetches(client().isFetching(filters?.()))\n\n const unsubscribe = queryCache().subscribe(() => {\n setFetches(client().isFetching(filters?.()))\n })\n\n onCleanup(unsubscribe)\n })\n\n return fetches\n}\n","import type {\n DefaultError,\n InfiniteData,\n NonUndefinedGuard,\n QueryKey,\n QueryKeyWithDataTag,\n} from '@tanstack/query-core'\nimport type { InfiniteQueryOptions } from './types'\nimport type { Accessor } from 'solid-js'\n\n/**\n * The options accepted by the `infiniteQueryOptions` overload selected when no `initialData` is set — `data`\n * may be `undefined` while the query is `pending`. `infiniteQueryOptions` itself accepts and returns a plain\n * object (its parameter type is `ReturnType<UndefinedInitialDataInfiniteOptions<...>>`, i.e. this `Accessor`\n * called); Solid's reactivity applies where the result is consumed instead, e.g.\n * `useInfiniteQuery(() => options)`.\n *\n * @template TQueryFnData - The type of a single page, as your `queryFn` resolves it.\n * @template TError - The type of errors your `queryFn` may throw.\n * @template TData - The type `data` ends up as after `select` runs — defaults to `InfiniteData<TQueryFnData>`,\n * the shape of all fetched pages plus their page params.\n * @template TQueryKey - The type of your `queryKey`.\n * @template TPageParam - The type of the parameter passed to `queryFn` to fetch a given page.\n */\nexport type UndefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n> = Accessor<\n InfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam> & {\n initialData?: undefined\n }\n>\n\n/**\n * The options accepted by the `infiniteQueryOptions` overload selected when `initialData` is set — `data` is\n * never `undefined`.\n *\n * @template TQueryFnData - The type of a single page, as your `queryFn` resolves it.\n * @template TError - The type of errors your `queryFn` may throw.\n * @template TData - The type `data` ends up as after `select` runs — defaults to `InfiniteData<TQueryFnData>`,\n * the shape of all fetched pages plus their page params.\n * @template TQueryKey - The type of your `queryKey`.\n * @template TPageParam - The type of the parameter passed to `queryFn` to fetch a given page.\n */\nexport type DefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError = DefaultError,\n // should we handle page param correctly\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n> = Accessor<\n InfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam> & {\n initialData:\n | NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>\n | (() => NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>)\n }\n>\n\n/**\n * You can generally pass everything to `infiniteQueryOptions` that you can also pass to `useInfiniteQuery`.\n * These options can be shared across hooks and imperative APIs such as `queryClient.infiniteQuery`.\n * `options.queryKey` is required and is the query key to generate options for.\n *\n * This overload is selected when `initialData` is set.\n *\n * @see {@link useInfiniteQuery} to run an infinite query with these options.\n * @param options - The {@link DefinedInitialDataInfiniteOptions} to use — everything you can pass to `useInfiniteQuery`, with `initialData` set.\n * @returns The same options object, typed so that `queryKey` carries the inferred data type.\n *\n * @example\n * ```tsx\n * import { For } from 'solid-js'\n * import { infiniteQueryOptions, useInfiniteQuery } from '@tanstack/solid-query'\n *\n * const projectsOptions = infiniteQueryOptions({\n * queryKey: ['projects'],\n * queryFn: ({ pageParam }) => fetchProjects(pageParam),\n * initialPageParam: 0,\n * getNextPageParam: (lastPage) => lastPage.nextId,\n * initialData: { pages: [], pageParams: [] },\n * })\n *\n * function Projects() {\n * // `projectsQuery.data` is never `undefined`, thanks to `initialData` — even if a refetch fails, so the\n * // list stays visible alongside the error.\n * const projectsQuery = useInfiniteQuery(() => projectsOptions)\n *\n * return (\n * <div>\n * {projectsQuery.isError ? <span>Error: {projectsQuery.error.message}</span> : null}\n * <ul>\n * <For each={projectsQuery.data.pages}>\n * {(page) => <For each={page.projects}>{(p) => <li>{p.name}</li>}</For>}\n * </For>\n * </ul>\n * </div>\n * )\n * }\n * ```\n */\nexport function infiniteQueryOptions<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: ReturnType<\n DefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >\n >,\n): ReturnType<\n DefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >\n> &\n QueryKeyWithDataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>\n\n/**\n * You can generally pass everything to `infiniteQueryOptions` that you can also pass to `useInfiniteQuery`.\n * These options can be shared across hooks and imperative APIs such as `queryClient.infiniteQuery`.\n * `options.queryKey` is required and is the query key to generate options for.\n *\n * @see {@link useInfiniteQuery} to run an infinite query with these options.\n * @param options - The {@link UndefinedInitialDataInfiniteOptions} to use — everything you can pass to `useInfiniteQuery`.\n * @returns The same options object, typed so that `queryKey` carries the inferred data type.\n *\n * @example\n * A parameterized factory, so the same options object can be reused per `postId`:\n * ```tsx\n * import { For, Match, Switch } from 'solid-js'\n * import { infiniteQueryOptions, useInfiniteQuery } from '@tanstack/solid-query'\n *\n * const commentsOptions = (postId: string) =>\n * infiniteQueryOptions({\n * queryKey: ['post', postId, 'comments'],\n * queryFn: ({ pageParam }) => fetchComments(postId, pageParam),\n * initialPageParam: 0,\n * getNextPageParam: (lastPage) => lastPage.nextId,\n * })\n *\n * function Comments(props: { postId: string }) {\n * const commentsQuery = useInfiniteQuery(() => commentsOptions(props.postId))\n *\n * return (\n * <Switch>\n * <Match when={commentsQuery.isPending}>Loading...</Match>\n * <Match when={commentsQuery.isError}>Error: {commentsQuery.error.message}</Match>\n * <Match when={commentsQuery.isSuccess}>\n * <ul>\n * <For each={commentsQuery.data.pages}>\n * {(page) => <For each={page.comments}>{(c) => <li>{c.text}</li>}</For>}\n * </For>\n * </ul>\n * </Match>\n * </Switch>\n * )\n * }\n * ```\n */\nexport function infiniteQueryOptions<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: ReturnType<\n UndefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >\n >,\n): ReturnType<\n UndefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >\n> &\n QueryKeyWithDataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>\n\nexport function infiniteQueryOptions(options: unknown) {\n return options\n}\n","import type { DefaultError, WithRequired } from '@tanstack/query-core'\nimport type { MutationOptions } from './types'\n\n/**\n * You can generally pass everything to `mutationOptions` that you can also pass to `useMutation`. A\n * `mutationKey` is required on this overload so the mutation can be looked up later, e.g. with\n * `useMutationState`.\n *\n * @see {@link useMutation} to run the mutation these options describe.\n * @param options - The mutation options to use, identical to what you'd pass to `useMutation`, with a\n * required `mutationKey`.\n * @returns The same options object, unchanged.\n *\n * @example\n * Looking the mutation up elsewhere via its `mutationKey`, e.g. for a global \"saving…\" indicator:\n * ```tsx\n * import { mutationOptions, useMutationState } from '@tanstack/solid-query'\n *\n * const createPostOptions = mutationOptions({\n * mutationKey: ['posts', 'create'],\n * mutationFn: createPost,\n * })\n *\n * function SavingIndicator() {\n * const isCreatingPost = useMutationState(() => ({\n * filters: { mutationKey: createPostOptions.mutationKey, status: 'pending' },\n * }))\n *\n * return isCreatingPost().length > 0 ? <span>Saving…</span> : null\n * }\n * ```\n */\nexport function mutationOptions<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TOnMutateResult = unknown,\n>(\n options: WithRequired<\n MutationOptions<TData, TError, TVariables, TOnMutateResult>,\n 'mutationKey'\n >,\n): WithRequired<\n MutationOptions<TData, TError, TVariables, TOnMutateResult>,\n 'mutationKey'\n>\n/**\n * You can generally pass everything to `mutationOptions` that you can also pass to `useMutation`. No\n * `mutationKey` is required on this overload — use this when you don't need to target the mutation via a\n * `mutationKey` filter later (e.g. with `useMutationState`); it can still be observed through other filters,\n * such as `status`.\n *\n * @see {@link useMutation} to run the mutation these options describe.\n * @param options - The mutation options to use, identical to what you'd pass to `useMutation`, without a\n * `mutationKey`.\n * @returns The same options object, unchanged.\n * @remarks See the other overload's example for looking a mutation up via `useMutationState`.\n *\n * @example\n * ```tsx\n * import { mutationOptions, useMutation } from '@tanstack/solid-query'\n *\n * const createPostOptions = mutationOptions({\n * mutationFn: createPost,\n * })\n *\n * function CreatePost() {\n * const createPostMutation = useMutation(() => createPostOptions)\n * return <button onClick={() => createPostMutation.mutate({ title: 'Hello' })}>Create</button>\n * }\n * ```\n */\nexport function mutationOptions<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TOnMutateResult = unknown,\n>(\n options: Omit<\n MutationOptions<TData, TError, TVariables, TOnMutateResult>,\n 'mutationKey'\n >,\n): Omit<\n MutationOptions<TData, TError, TVariables, TOnMutateResult>,\n 'mutationKey'\n>\nexport function mutationOptions<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TOnMutateResult = unknown,\n>(\n options: MutationOptions<TData, TError, TVariables, TOnMutateResult>,\n): MutationOptions<TData, TError, TVariables, TOnMutateResult> {\n return options\n}\n","import { createEffect, createMemo, createSignal, onCleanup } from 'solid-js'\nimport { useQueryClientResolver } from './QueryClientProvider'\nimport type { MutationFilters } from '@tanstack/query-core'\nimport type { QueryClient } from './QueryClient'\nimport type { Accessor } from 'solid-js'\n\n/**\n * The `useIsMutating` primitive returns the `number` of mutations that your application currently has `pending`\n * (useful for app-wide loading indicators).\n *\n * @param filters - An accessor returning the {@link MutationFilters} to narrow down the matched mutations.\n * @param queryClient - An accessor for a custom `QueryClient`. Otherwise, the one from the nearest context\n * will be used.\n * @returns An accessor for the `number` of the mutations that your application currently has `pending`.\n *\n * @example\n * ```tsx\n * import { useIsMutating } from '@tanstack/solid-query'\n *\n * function PostsMutatingIndicator() {\n * // How many mutations matching the posts prefix are in progress?\n * const isMutatingPosts = useIsMutating(() => ({ mutationKey: ['posts'] }))\n *\n * return isMutatingPosts() > 0 ? <span>Saving posts...</span> : null\n * }\n * ```\n */\nexport function useIsMutating(\n filters?: Accessor<MutationFilters>,\n queryClient?: Accessor<QueryClient>,\n): Accessor<number> {\n const resolveClient = useQueryClientResolver(queryClient)\n const client = createMemo(() => resolveClient())\n const mutationCache = createMemo(() => client().getMutationCache())\n\n const [mutations, setMutations] = createSignal(\n client().isMutating(filters?.()),\n )\n\n createEffect(() => {\n setMutations(client().isMutating(filters?.()))\n\n const unsubscribe = mutationCache().subscribe(() => {\n setMutations(client().isMutating(filters?.()))\n })\n\n onCleanup(unsubscribe)\n })\n\n return mutations\n}\n","import { createEffect, createMemo, createSignal, onCleanup } from 'solid-js'\nimport { replaceEqualDeep } from '@tanstack/query-core'\nimport { useQueryClientResolver } from './QueryClientProvider'\nimport type {\n Mutation,\n MutationCache,\n MutationFilters,\n MutationState,\n} from '@tanstack/query-core'\nimport type { Accessor } from 'solid-js'\nimport type { QueryClient } from './QueryClient'\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\ntype MutationStateOptions<\n TResult = MutationState,\n TMutation extends Mutation<any, any, any, any> =\n MutationTypeFromResult<TResult>,\n> = {\n filters?: MutationFilters\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 primitive that gives you access to all mutations in the `MutationCache`. You can pass\n * `filters` ({@link MutationFilters}) to narrow down your mutations, and `select` to transform the mutation\n * state.\n *\n * @param options - An accessor returning the `filters` to narrow down matched mutations, and an optional\n * `select` to transform the mutation state.\n * @param queryClient - An accessor for a custom `QueryClient`. Otherwise, the one from the nearest context\n * will be used.\n * @returns An accessor for an array of whatever `select` returns for each matching mutation.\n *\n * @example\n * Get all variables of all running mutations:\n * ```tsx\n * import { useMutationState } from '@tanstack/solid-query'\n *\n * function PendingPosts() {\n * const pendingVariables = useMutationState(() => ({\n * filters: { status: 'pending' },\n * select: (mutation) => mutation.state.variables,\n * }))\n *\n * return <>{pendingVariables().length} posts saving...</>\n * }\n * ```\n *\n * @example\n * Get all data for specific mutations via the `mutationKey`:\n * ```tsx\n * import { useMutation, useMutationState } from '@tanstack/solid-query'\n *\n * const mutationKey = ['posts']\n *\n * function Posts() {\n * // Some mutation that we want to get the state for\n * const createPostsMutation = 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 *\n * return (\n * <button onClick={() => createPostsMutation.mutate(['New Post'])}>\n * Create post ({savedPosts().length} saved so far)\n * </button>\n * )\n * }\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 * ```tsx\n * import { useMutationState } from '@tanstack/solid-query'\n *\n * function LatestPost() {\n * const savedPosts = useMutationState(() => ({\n * filters: { mutationKey: ['posts'], status: 'success' },\n * select: (mutation) => mutation.state.data,\n * }))\n *\n * const latestPost = () => savedPosts()[savedPosts().length - 1]\n *\n * return <span>{latestPost()?.title}</span>\n * }\n * ```\n */\nexport function useMutationState<\n TResult = MutationState,\n TMutation extends Mutation<any, any, any, any> =\n MutationTypeFromResult<TResult>,\n>(\n options: Accessor<MutationStateOptions<TResult, TMutation>> = () => ({}),\n queryClient?: Accessor<QueryClient>,\n): Accessor<Array<TResult>> {\n const resolveClient = useQueryClientResolver(queryClient)\n const client = createMemo(() => resolveClient())\n const mutationCache = createMemo(() => client().getMutationCache())\n\n const [result, setResult] = createSignal(\n getResult(mutationCache(), options()),\n )\n\n createEffect(() => {\n const unsubscribe = mutationCache().subscribe(() => {\n const nextResult = replaceEqualDeep(\n result(),\n getResult(mutationCache(), options()),\n )\n if (result() !== nextResult) {\n setResult(nextResult)\n }\n })\n\n onCleanup(unsubscribe)\n })\n\n return result\n}\n","/* istanbul ignore file */\n\nimport { useQuery } from './useQuery'\nimport { useInfiniteQuery } from './useInfiniteQuery'\nimport { useMutation } from './useMutation'\nimport { useQueries } from './useQueries'\n\n// Re-export core\nexport * from '@tanstack/query-core'\n\n// Solid Query\nexport * from './types'\n\nexport type {\n DefinedUseBaseQueryResult,\n DefinedUseInfiniteQueryResult,\n DefinedUseQueryResult,\n InfiniteQueryOptions,\n MutationOptions,\n QueryOptions,\n UseBaseMutationResult,\n UseBaseQueryOptions,\n UseBaseQueryResult,\n UseInfiniteQueryOptions,\n UseInfiniteQueryResult,\n UseMutateAsyncFunction,\n UseMutateFunction,\n UseMutationOptions,\n UseMutationResult,\n UseQueryOptions,\n UseQueryResult,\n // Aliases (create* and use* are both supported)\n UseBaseQueryOptions as CreateBaseQueryOptions,\n UseBaseQueryResult as CreateBaseQueryResult,\n UseInfiniteQueryOptions as CreateInfiniteQueryOptions,\n UseInfiniteQueryResult as CreateInfiniteQueryResult,\n UseMutateAsyncFunction as CreateMutateAsyncFunction,\n UseMutateFunction as CreateMutateFunction,\n UseMutationOptions as CreateMutationOptions,\n UseMutationResult as CreateMutationResult,\n UseBaseMutationResult as CreateBaseMutationResult,\n UseQueryOptions as CreateQueryOptions,\n UseQueryResult as CreateQueryResult,\n DefinedUseBaseQueryResult as DefinedCreateBaseQueryResult,\n DefinedUseInfiniteQueryResult as DefinedCreateInfiniteQueryResult,\n DefinedUseQueryResult as DefinedCreateQueryResult,\n} from './types'\n\nexport { QueryClient } from './QueryClient'\nexport type {\n QueryObserverOptions,\n DefaultOptions,\n QueryClientConfig,\n InfiniteQueryObserverOptions,\n} from './QueryClient'\nexport { useQuery } from './useQuery'\nexport const createQuery = useQuery\nexport { queryOptions } from './queryOptions'\nexport type {\n DefinedInitialDataOptions,\n UndefinedInitialDataOptions,\n} from './queryOptions'\nexport {\n QueryClientContext,\n QueryClientProvider,\n useQueryClient,\n} from './QueryClientProvider'\nexport type { QueryClientProviderProps } from './QueryClientProvider'\nexport { useIsFetching } from './useIsFetching'\nexport { useIsFetching as createIsFetching } from './useIsFetching'\nexport { useInfiniteQuery }\nexport const createInfiniteQuery = useInfiniteQuery\nexport { infiniteQueryOptions } from './infiniteQueryOptions'\nexport type {\n DefinedInitialDataInfiniteOptions,\n UndefinedInitialDataInfiniteOptions,\n} from './infiniteQueryOptions'\nexport { useMutation } from './useMutation'\nexport { mutationOptions } from './mutationOptions'\nexport const createMutation = useMutation\nexport { useIsMutating } from './useIsMutating'\nexport { useIsMutating as createIsMutating } from './useIsMutating'\nexport { useMutationState } from './useMutationState'\nexport { useMutationState as createMutationState } from './useMutationState'\nexport { useQueries } from './useQueries'\nexport const createQueries = useQueries\nexport { useIsRestoring, IsRestoringProvider } from './isRestoring'\n"],"mappings":"qnBAYA,MAAaO,EAAqBP,EAEhCQ,IAAAA,EAAS,EAELC,EACJ,yDAUWC,EAAkBC,GAA8B,CAC3D,GAAIA,EACF,OAAOA,EAET,IAAMC,EAAST,EAAWI,CAAkB,EAE5C,GAAI,CAACK,EACH,MAAUC,MAAMJ,CAAuB,EAGzC,OAAOG,EAAO,CAChB,EAEaE,EACXH,GAC0B,CAC1B,IAAMI,EAAgBZ,EAAWI,CAAkB,EAEnD,UAAa,CACX,IAAMS,EAAiBL,IAAc,EACrC,GAAIK,EACF,OAAOA,EAGT,GAAI,CAACD,EACH,MAAUF,MAAMJ,CAAuB,EAGzC,OAAOM,EAAc,CACvB,CACF,EAqCaK,EACXC,IAEApB,EAAgCqB,IAC9BA,IAAU,EACVD,EAAMT,OAAOW,MAAM,EACZF,EAAMT,OAAOU,QAAQE,KAAKH,EAAMT,MAAM,EAC9C,EACDV,MAAgBmB,EAAMT,OAAOU,QAAQ,CAAC,EAEtCG,EACGlB,EAAmBmB,SAAQ,CAACC,UAAaN,EAAMT,OAAM,IAAAM,UAAA,CAAA,OACnDG,EAAMH,QAAQ,CAAA,CAAA,GCvGf,EAAqB,MAAuC,EAAK,EAS1D,MAAuB,EAAW,CA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Aa,EAC1B,EAAU,EAAc,EAAG,EAAQ,CAAC,CACtC,EAgBA,OAdA,MAAmB,CACjB,IAAM,EAAc,EAAc,CAAC,CAAC,cAAgB,CAClD,IAAM,EAAa,EACjB,EAAO,EACP,EAAU,EAAc,EAAG,EAAQ,CAAC,CACtC,EACI,EAAO,IAAM,GACf,EAAU,CAAU,CAExB,CAAC,EAED,EAAU,CAAW,CACvB,CAAC,EAEM,CACT,CClGA,MAAa,EAAc,EAed,EAAsB,EAQtB,EAAiB,EAMjB,GAAgB"}
1
+ {"version":3,"file":"index.js","names":["createContext","createRenderEffect","onCleanup","useContext","QueryClient","Accessor","JSX","QueryClientContext","undefined","queryClientContextError","useQueryClient","queryClient","client","Error","useQueryClientResolver","contextClient","resolvedClient","QueryClientProviderProps","children","Element","QueryClientProvider","props","unmount","mount","bind","_$createComponent","Provider","value","_$createComponent","QueryCoreClient","QueryClient$1","QueryClientContext","createContext","queryClientContextError","useQueryClient","queryClient","client","useContext","useQueryClientResolver","contextClient","resolvedClient","QueryClientProvider","createRenderEffect","unmount","props","onCleanup","createComponent","IsRestoringContext","useIsRestoring","IsRestoringProvider","reconcileFn","reconcileOption","result","newData","store","data","reconcile","hydratableObserverResult","isServer","obj","unwrap","query","useBaseQuery","resolveClient","createMemo","isRestoring","unsubscribeQueued","defaultedOptions","defaultOptions","options","initialOptions","observer","setObserver","createSignal","Observer","observerResult","state","setState","createStore","createServerSubscriber","notifyManager","unwrappedResult","reject","unsubscribeIfQueued","resolve","unsubscribe","createClientSubscriber","refetch","setStateWithReconciliation","opts","reconcileOptions","res","createDeepSignal","unwrapped","v","rest","resolver","queryResource","createResource","obs","shouldThrowError","info","hydrate","newOptions","createComputed","on","newObserver","c","restoring","prop","target","useQuery","QueryObserver","useInfiniteQuery","InfiniteQueryObserver","useMutation","MutationObserver","mutate","args","noop","useQueries","defaultedQueries","queriesOptions","mergeProps","QueriesObserver","dataResources","queryRes","batch","dataResources_","index","dataResource","taskQueue","subscribeToObserver","taskToRun","cleanup","onMount","handler","getProxies","s","proxyState","setProxyState","QueryClient","config","queryOptions","useIsFetching","queryCache","fetches","setFetches","filters","createEffect","infiniteQueryOptions","mutationOptions","useIsMutating","mutationCache","mutations","setMutations","getResult","mutation","useMutationState","setResult","nextResult","replaceEqualDeep","createQuery","createInfiniteQuery","createMutation","createQueries"],"sources":["../src/QueryClientProvider.tsx","../src/isRestoring.ts","../src/useBaseQuery.ts","../src/useQuery.ts","../src/useInfiniteQuery.ts","../src/useMutation.ts","../src/useQueries.ts","../src/QueryClient.ts","../src/queryOptions.ts","../src/useIsFetching.ts","../src/infiniteQueryOptions.ts","../src/mutationOptions.ts","../src/useIsMutating.ts","../src/useMutationState.ts","../src/index.ts"],"sourcesContent":["import {\n createContext,\n createRenderEffect,\n onCleanup,\n useContext,\n} from 'solid-js'\nimport type { QueryClient } from './QueryClient'\nimport type { Accessor, JSX } from 'solid-js'\n\n/**\n * The context that `useQueryClient` reads from. `QueryClientProvider` is the normal way to set it.\n */\nexport const QueryClientContext = createContext<\n (() => QueryClient) | undefined\n>(undefined)\n\nconst queryClientContextError =\n 'No QueryClient set, use QueryClientProvider to set one'\n\n/**\n * The `useQueryClient` primitive returns the current `QueryClient` instance.\n *\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will\n * be used.\n * @returns The current `QueryClient` instance.\n * @throws If no `queryClient` argument is passed and no `QueryClientProvider` is found in the component tree.\n */\nexport const useQueryClient = (queryClient?: QueryClient) => {\n if (queryClient) {\n return queryClient\n }\n const client = useContext(QueryClientContext)\n\n if (!client) {\n throw new Error(queryClientContextError)\n }\n\n return client()\n}\n\nexport const useQueryClientResolver = (\n queryClient?: Accessor<QueryClient | undefined>,\n): Accessor<QueryClient> => {\n const contextClient = useContext(QueryClientContext)\n\n return () => {\n const resolvedClient = queryClient?.()\n if (resolvedClient) {\n return resolvedClient\n }\n\n if (!contextClient) {\n throw new Error(queryClientContextError)\n }\n\n return contextClient()\n }\n}\n\n/**\n * The props accepted by `QueryClientProvider`.\n */\nexport type QueryClientProviderProps = {\n /**\n * **Required**\n *\n * The `QueryClient` instance to provide.\n */\n client: QueryClient\n /**\n * The components that get access to the provided `QueryClient`.\n */\n children?: JSX.Element\n}\n\n/**\n * Use the `QueryClientProvider` component to connect and provide a `QueryClient` to your application. Also\n * calls `client.mount()`/`client.unmount()` as this component mounts/unmounts, which subscribes the client to\n * focus/online events (resuming any paused mutations and refetching as needed when the app regains focus or\n * comes back online).\n *\n * @returns The provided `children`, wrapped so they can read the `QueryClient` via `useQueryClient`.\n *\n * @example\n * ```tsx\n * import { QueryClient, QueryClientProvider } from '@tanstack/solid-query'\n *\n * const queryClient = new QueryClient()\n *\n * function App() {\n * return <QueryClientProvider client={queryClient}>...</QueryClientProvider>\n * }\n * ```\n */\nexport const QueryClientProvider = (\n props: QueryClientProviderProps,\n): JSX.Element => {\n createRenderEffect<() => void>((unmount) => {\n unmount?.()\n props.client.mount()\n return props.client.unmount.bind(props.client)\n })\n onCleanup(() => props.client.unmount())\n\n return (\n <QueryClientContext.Provider value={() => props.client}>\n {props.children}\n </QueryClientContext.Provider>\n )\n}\n","import { createContext, useContext } from 'solid-js'\nimport type { Accessor } from 'solid-js'\n\nconst IsRestoringContext = createContext<Accessor<boolean>>(() => false)\n\n/**\n * If you are using `PersistQueryClientProvider`, you can also use the `useIsRestoring` primitive alongside it to\n * check if a restore is currently in progress. `useQuery` and friends also check this internally to avoid\n * race conditions between the restore and mounting queries.\n *\n * @returns An accessor that reads `true` while a persisted client is being restored, `false` otherwise.\n */\nexport const useIsRestoring = () => useContext(IsRestoringContext)\n\n/**\n * The Provider that `PersistQueryClientProvider` uses to signal whether a persisted client is currently\n * being restored, read by `useIsRestoring`.\n */\nexport const IsRestoringProvider = IsRestoringContext.Provider\n","// Had to disable the lint rule because isServer type is defined as false\n// in solid-js/web package. I'll create a GitHub issue with them to see\n// why that happens.\nimport { hydrate, notifyManager, shouldThrowError } from '@tanstack/query-core'\nimport { isServer } from 'solid-js/web'\nimport {\n createComputed,\n createMemo,\n createResource,\n createSignal,\n on,\n onCleanup,\n} from 'solid-js'\nimport { createStore, reconcile, unwrap } from 'solid-js/store'\nimport { useQueryClientResolver } from './QueryClientProvider'\nimport { useIsRestoring } from './isRestoring'\nimport type { UseBaseQueryOptions } from './types'\nimport type { Accessor, Signal } from 'solid-js'\nimport type { QueryClient } from './QueryClient'\nimport type {\n Query,\n QueryKey,\n QueryObserver,\n QueryObserverResult,\n} from '@tanstack/query-core'\n\nfunction reconcileFn<TData, TError>(\n store: QueryObserverResult<TData, TError>,\n result: QueryObserverResult<TData, TError>,\n reconcileOption:\n string | false | ((oldData: TData | undefined, newData: TData) => TData),\n queryHash?: string,\n): QueryObserverResult<TData, TError> {\n if (reconcileOption === false) return result\n if (typeof reconcileOption === 'function') {\n const newData = reconcileOption(store.data, result.data as TData)\n return { ...result, data: newData } as typeof result\n }\n let data = result.data\n if (store.data === undefined) {\n try {\n data = structuredClone(data)\n } catch (error) {\n if (process.env.NODE_ENV !== 'production') {\n if (error instanceof Error) {\n console.warn(\n `Unable to correctly reconcile data for query key: ${queryHash}. ` +\n `Possibly because the query data contains data structures that aren't supported ` +\n `by the 'structuredClone' algorithm. Consider using a callback function instead ` +\n `to manage the reconciliation manually.\\n\\n Error Received: ${error.name} - ${error.message}`,\n )\n }\n }\n }\n }\n const newData = reconcile(data, { key: reconcileOption })(store.data)\n return { ...result, data: newData } as typeof result\n}\n\n/**\n * Solid's `onHydrated` functionality will silently \"fail\" (hydrate with an empty object)\n * if the resource data is not serializable.\n */\nconst hydratableObserverResult = <\n TQueryFnData,\n TError,\n TData,\n TQueryKey extends QueryKey,\n TDataHydratable,\n>(\n query: Query<TQueryFnData, TError, TData, TQueryKey>,\n result: QueryObserverResult<TDataHydratable, TError>,\n) => {\n if (!isServer) return result\n const obj: any = {\n ...unwrap(result),\n // During SSR, functions cannot be serialized, so we need to remove them\n // This is safe because we will add these functions back when the query is hydrated\n refetch: undefined,\n }\n\n // If the query is an infinite query, we need to remove additional properties\n if ('fetchNextPage' in result) {\n obj.fetchNextPage = undefined\n obj.fetchPreviousPage = undefined\n }\n\n // We will also attach the dehydrated state of the query to the result\n // This will be removed on client after hydration\n obj.hydrationData = {\n state: query.state,\n queryKey: query.queryKey,\n queryHash: query.queryHash,\n ...(query.meta && { meta: query.meta }),\n }\n\n return obj\n}\n\n// Base Query Function that is used to create the query.\nexport function useBaseQuery<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey extends QueryKey,\n>(\n options: Accessor<\n UseBaseQueryOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey>\n >,\n Observer: typeof QueryObserver,\n queryClient?: Accessor<QueryClient>,\n) {\n type ResourceData = QueryObserverResult<TData, TError>\n\n const resolveClient = useQueryClientResolver(queryClient)\n const client = createMemo(() => resolveClient())\n const isRestoring = useIsRestoring()\n // There are times when we run a query on the server but the resource is never read\n // This could lead to times when the queryObserver is unsubscribed before the resource has loaded\n // Causing a time out error. To prevent this we will queue the unsubscribe if the cleanup is called\n // before the resource has loaded\n let unsubscribeQueued = false\n\n const defaultedOptions = createMemo(() => {\n const defaultOptions = client().defaultQueryOptions(options())\n defaultOptions._optimisticResults = isRestoring()\n ? 'isRestoring'\n : 'optimistic'\n defaultOptions.structuralSharing = false\n if (isServer) {\n defaultOptions.retry = false\n defaultOptions.throwOnError = true\n }\n return defaultOptions\n })\n const initialOptions = defaultedOptions()\n\n const [observer, setObserver] = createSignal(\n new Observer(client(), defaultedOptions()),\n )\n\n let observerResult = observer().getOptimisticResult(defaultedOptions())\n const [state, setState] =\n createStore<QueryObserverResult<TData, TError>>(observerResult)\n\n const createServerSubscriber = (\n resolve: (\n data: ResourceData | PromiseLike<ResourceData | undefined> | undefined,\n ) => void,\n reject: (reason?: any) => void,\n ) => {\n return observer().subscribe((result) => {\n notifyManager.batchCalls(() => {\n const query = observer().getCurrentQuery()\n const unwrappedResult = hydratableObserverResult(query, result)\n\n if (result.data !== undefined && unwrappedResult.isError) {\n reject(unwrappedResult.error)\n unsubscribeIfQueued()\n } else {\n resolve(unwrappedResult)\n unsubscribeIfQueued()\n }\n })()\n })\n }\n\n const unsubscribeIfQueued = () => {\n if (unsubscribeQueued) {\n unsubscribe?.()\n unsubscribeQueued = false\n }\n }\n\n const createClientSubscriber = () => {\n const obs = observer()\n return obs.subscribe((result) => {\n observerResult = result\n queueMicrotask(() => {\n if (unsubscribe) {\n refetch()\n }\n })\n })\n }\n\n function setStateWithReconciliation(res: typeof observerResult) {\n const opts = observer().options\n // @ts-expect-error - Reconcile option is not correctly typed internally\n const reconcileOptions = opts.reconcile\n\n setState((store) => {\n return reconcileFn(\n store,\n res,\n reconcileOptions === undefined ? false : reconcileOptions,\n opts.queryHash,\n )\n })\n }\n\n function createDeepSignal<T>(): Signal<T> {\n return [\n () => state,\n (v: any) => {\n const unwrapped = unwrap(state)\n if (typeof v === 'function') {\n v = v(unwrapped)\n }\n // Hydration data exists on first load after SSR,\n // and should be removed from the observer result\n if (v?.hydrationData) {\n const { hydrationData, ...rest } = v\n v = rest\n }\n setStateWithReconciliation(v)\n },\n ] as Signal<T>\n }\n\n /**\n * Unsubscribe is set lazily, so that we can subscribe after hydration when needed.\n */\n let unsubscribe: (() => void) | null = null\n\n /*\n Fixes #7275\n In a few cases, the observer could unmount before the resource is loaded.\n This leads to Suspense boundaries to be suspended indefinitely.\n This resolver will be called when the observer is unmounting\n but the resource is still in a loading state\n */\n let resolver: ((value: ResourceData) => void) | null = null\n const [queryResource, { refetch }] = createResource<ResourceData | undefined>(\n () => {\n const obs = observer()\n return new Promise((resolve, reject) => {\n resolver = resolve\n if (isServer) {\n unsubscribe = createServerSubscriber(resolve, reject)\n } else if (!unsubscribe && !isRestoring()) {\n unsubscribe = createClientSubscriber()\n }\n obs.updateResult()\n\n if (\n observerResult.isError &&\n !observerResult.isFetching &&\n !isRestoring() &&\n shouldThrowError(obs.options.throwOnError, [\n observerResult.error,\n obs.getCurrentQuery(),\n ])\n ) {\n setStateWithReconciliation(observerResult)\n return reject(observerResult.error)\n }\n if (!observerResult.isLoading) {\n resolver = null\n return resolve(\n hydratableObserverResult(obs.getCurrentQuery(), observerResult),\n )\n }\n\n setStateWithReconciliation(observerResult)\n })\n },\n {\n storage: createDeepSignal,\n\n get deferStream() {\n return options().deferStream\n },\n\n /**\n * If this resource was populated on the server (either sync render, or streamed in over time), onHydrated\n * will be called. This is the point at which we can hydrate the query cache state, and setup the query subscriber.\n *\n * Leveraging onHydrated allows us to plug into the async and streaming support that solidjs resources already support.\n *\n * Note that this is only invoked on the client, for queries that were originally run on the server.\n */\n onHydrated(_k, info) {\n if (info.value && 'hydrationData' in info.value) {\n hydrate(client(), {\n // @ts-expect-error - hydrationData is not correctly typed internally\n queries: [{ ...info.value.hydrationData }],\n })\n }\n\n if (unsubscribe) return\n /**\n * Do not refetch query on mount if query was fetched on server,\n * even if `staleTime` is not set.\n */\n const newOptions = { ...initialOptions }\n if (\n (initialOptions.staleTime || !initialOptions.initialData) &&\n info.value\n ) {\n newOptions.refetchOnMount = false\n }\n // Setting the options as an immutable object to prevent\n // wonky behavior with observer subscriptions\n observer().setOptions(newOptions)\n setStateWithReconciliation(observer().getOptimisticResult(newOptions))\n unsubscribe = createClientSubscriber()\n },\n },\n )\n\n createComputed(\n on(\n client,\n (c) => {\n if (unsubscribe) {\n unsubscribe()\n }\n const newObserver = new Observer(c, defaultedOptions())\n unsubscribe = createClientSubscriber()\n setObserver(newObserver)\n },\n {\n defer: true,\n },\n ),\n )\n\n createComputed(\n on(\n isRestoring,\n (restoring) => {\n if (!restoring && !isServer) {\n refetch()\n }\n },\n { defer: true },\n ),\n )\n\n onCleanup(() => {\n if (isServer && queryResource.state === 'pending') {\n unsubscribeQueued = true\n return\n }\n if (unsubscribe) {\n unsubscribe()\n unsubscribe = null\n }\n if (resolver && !isServer) {\n resolver(observerResult)\n resolver = null\n }\n })\n\n createComputed(\n on(\n [observer, defaultedOptions],\n ([obs, opts]) => {\n obs.setOptions(opts)\n setStateWithReconciliation(obs.getOptimisticResult(opts))\n refetch()\n },\n { defer: true },\n ),\n )\n\n const handler = {\n get(\n target: QueryObserverResult<TData, TError>,\n prop: keyof QueryObserverResult<TData, TError>,\n ): any {\n if (prop === 'data') {\n if (state.data !== undefined) {\n return queryResource.latest?.data\n }\n return queryResource()?.data\n }\n return Reflect.get(target, prop)\n },\n }\n\n return new Proxy(state, handler)\n}\n","import { QueryObserver } from '@tanstack/query-core'\nimport { createMemo } from 'solid-js'\nimport { useBaseQuery } from './useBaseQuery'\nimport type { DefaultError, QueryKey } from '@tanstack/query-core'\nimport type { QueryClient } from './QueryClient'\nimport type { Accessor } from 'solid-js'\nimport type {\n DefinedUseQueryResult,\n UseQueryOptions,\n UseQueryResult,\n} from './types'\nimport type {\n DefinedInitialDataOptions,\n UndefinedInitialDataOptions,\n} from './queryOptions'\n\n/**\n * Subscribes to a query: a declarative dependency on an asynchronous source of data that is tied to a unique key.\n * The query runs when the options call for it — `enabled: false` skips the initial fetch.\n *\n * @see {@link queryOptions} to share these options between `useQuery` and imperative APIs like `queryClient.query`.\n * @param options - An accessor returning the {@link UndefinedInitialDataOptions} to use — everything you can\n * pass to `useQuery`.\n * @param queryClient - An accessor for a custom `QueryClient`. Otherwise, the one from the nearest context\n * will be used.\n * @returns The current query result, as a Solid store. `status` is `pending` if there is no cached data to\n * display, `error` if the last fetch attempt failed, or `success` if the query has data to display.\n * `isPending`/`isSuccess`/`isError` are derived booleans for convenience.\n *\n * @example\n * ```tsx\n * import { For, Match, Switch } from 'solid-js'\n * import { useQuery } from '@tanstack/solid-query'\n *\n * function Posts() {\n * const postsQuery = useQuery(() => ({\n * queryKey: ['posts'],\n * queryFn: fetchPosts,\n * }))\n *\n * return (\n * <Switch>\n * <Match when={postsQuery.isPending}>Loading...</Match>\n * <Match when={postsQuery.isError}>Error: {postsQuery.error.message}</Match>\n * <Match when={postsQuery.isSuccess}>\n * <ul>\n * <For each={postsQuery.data}>{(post) => <li>{post.title}</li>}</For>\n * </ul>\n * <div>{postsQuery.isFetching ? 'Background Updating...' : ' '}</div>\n * </Match>\n * </Switch>\n * )\n * }\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 * ```tsx\n * import { Match, Switch } from 'solid-js'\n * import { useQuery } from '@tanstack/solid-query'\n *\n * function PostCount() {\n * const postsQuery = useQuery(() => ({\n * queryKey: ['posts'],\n * queryFn: fetchPosts,\n * select: (posts) => posts.length,\n * }))\n *\n * return (\n * <Switch>\n * <Match when={postsQuery.isPending}>Loading...</Match>\n * <Match when={postsQuery.isError}>Error: {postsQuery.error.message}</Match>\n * <Match when={postsQuery.isSuccess}>{postsQuery.data} posts</Match>\n * </Switch>\n * )\n * }\n * ```\n *\n * @example\n * A dependent query, only enabled once `postId` is set:\n * ```tsx\n * import { Match, Switch } from 'solid-js'\n * import { useQuery } from '@tanstack/solid-query'\n *\n * function Post(props: { postId: number | undefined }) {\n * const postQuery = useQuery(() => ({\n * queryKey: ['post', props.postId],\n * queryFn: () => fetchPost(props.postId!),\n * enabled: props.postId != null,\n * }))\n *\n * return (\n * <Switch fallback={<h1>{postQuery.data?.title}</h1>}>\n * <Match when={props.postId == null}>Select a post</Match>\n * <Match when={postQuery.isLoading}>Loading...</Match>\n * <Match when={postQuery.isError}>Error: {postQuery.error.message}</Match>\n * </Switch>\n * )\n * }\n * ```\n *\n * @example\n * The same dependent query, using `skipToken` to disable it in a type-safe way instead of relying on\n * `enabled`. The non-null assertion is still needed — Solid's `props` narrowing doesn't survive into the\n * `queryFn` closure the way a local `const` would — but `skipToken` keeps `queryFn`'s return type accurate\n * without it. `refetch` doesn't work while `queryFn` is `skipToken` — use `enabled: false` instead if you\n * need to trigger the query manually:\n * ```tsx\n * import { Match, Switch } from 'solid-js'\n * import { skipToken, useQuery } from '@tanstack/solid-query'\n *\n * function Post(props: { postId: number | undefined }) {\n * const postQuery = useQuery(() => ({\n * queryKey: ['post', props.postId],\n * queryFn: props.postId != null ? () => fetchPost(props.postId!) : skipToken,\n * }))\n *\n * return (\n * <Switch fallback={<h1>{postQuery.data?.title}</h1>}>\n * <Match when={props.postId == null}>Select a post</Match>\n * <Match when={postQuery.isLoading}>Loading...</Match>\n * <Match when={postQuery.isError}>Error: {postQuery.error.message}</Match>\n * </Switch>\n * )\n * }\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 * ```tsx\n * import { useQuery, useQueryClient } from '@tanstack/solid-query'\n *\n * function Post(props: { postId: number }) {\n * const queryClient = useQueryClient()\n *\n * const postQuery = 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 *\n * return postQuery.isError ? <span>Error: {postQuery.error.message}</span> : <h1>{postQuery.data?.title}</h1>\n * }\n * ```\n *\n * @example\n * Paginated data, keeping the previous page's data visible while the next page loads:\n * ```tsx\n * import { For, createSignal } from 'solid-js'\n * import { keepPreviousData, useQuery } from '@tanstack/solid-query'\n *\n * function Posts() {\n * const [page, setPage] = createSignal(0)\n *\n * const postsQuery = useQuery(() => ({\n * queryKey: ['posts', page()],\n * queryFn: () => fetchPosts(page()),\n * placeholderData: keepPreviousData,\n * }))\n *\n * return (\n * <div>\n * <ul>\n * <For each={postsQuery.data}>{(post) => <li>{post.title}</li>}</For>\n * </ul>\n * <button\n * disabled={postsQuery.isPlaceholderData}\n * onClick={() => setPage((old) => old + 1)}\n * >\n * Next Page\n * </button>\n * </div>\n * )\n * }\n * ```\n */\nexport function useQuery<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: UndefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>,\n queryClient?: () => QueryClient,\n): UseQueryResult<TData, TError>\n\n/**\n * Subscribes to a query: a declarative dependency on an asynchronous source of data that is tied to a unique key.\n * The query runs when the options call for it — `enabled: false` skips the initial fetch.\n *\n * This overload is selected when `initialData` is set, so the resulting `data` is never `undefined` (unless\n * a `select` changes `TData` to include `undefined`).\n *\n * @see {@link queryOptions} to share these options between `useQuery` and imperative APIs like `queryClient.query`.\n * @param options - An accessor returning the {@link DefinedInitialDataOptions} to use — everything you can\n * pass to `useQuery`, with `initialData` set.\n * @param queryClient - An accessor for a custom `QueryClient`. Otherwise, the one from the nearest context\n * will be used.\n * @returns The current query result, as a Solid store, typed so that `status` is `success` — or `error` if a\n * fetch attempt fails while keeping the existing data (`status` never resolves to `pending` in this overload's\n * type, since `initialData` guarantees data upfront). `isSuccess`/`isError` are derived booleans for\n * convenience.\n *\n * @example\n * ```tsx\n * import { For } from 'solid-js'\n * import { useQuery } from '@tanstack/solid-query'\n *\n * function Posts() {\n * // `postsQuery.data` is never `undefined`, thanks to `initialData` — even if a refetch fails, so the\n * // list stays visible alongside the error.\n * const postsQuery = useQuery(() => ({\n * queryKey: ['posts'],\n * queryFn: fetchPosts,\n * initialData: [],\n * }))\n *\n * return (\n * <div>\n * {postsQuery.isError ? <span>Error: {postsQuery.error.message}</span> : null}\n * <ul>\n * <For each={postsQuery.data}>{(post) => <li>{post.title}</li>}</For>\n * </ul>\n * </div>\n * )\n * }\n * ```\n */\nexport function useQuery<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: DefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>,\n queryClient?: () => QueryClient,\n): DefinedUseQueryResult<TData, TError>\nexport function useQuery<\n TQueryFnData,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>,\n queryClient?: Accessor<QueryClient>,\n) {\n return useBaseQuery(\n createMemo(() => options()),\n QueryObserver,\n queryClient,\n )\n}\n","import { InfiniteQueryObserver } from '@tanstack/query-core'\nimport { createMemo } from 'solid-js'\nimport { useBaseQuery } from './useBaseQuery'\nimport type {\n DefaultError,\n InfiniteData,\n QueryKey,\n QueryObserver,\n} from '@tanstack/query-core'\nimport type { QueryClient } from './QueryClient'\nimport type {\n DefinedUseInfiniteQueryResult,\n UseInfiniteQueryOptions,\n UseInfiniteQueryResult,\n} from './types'\nimport type { Accessor } from 'solid-js'\nimport type {\n DefinedInitialDataInfiniteOptions,\n UndefinedInitialDataInfiniteOptions,\n} from './infiniteQueryOptions'\n\n/**\n * The options for `useInfiniteQuery` are identical to `useQuery`, with the addition of\n * `initialPageParam`, `getNextPageParam`, `getPreviousPageParam`, and `maxPages`.\n *\n * This overload is selected when `initialData` is set.\n *\n * @remarks Keep in mind that imperative fetch calls, such as `fetchNextPage`, may interfere with the default\n * refetch behavior, resulting in outdated data. Make sure to call these functions only in response to user\n * actions, or add conditions like `hasNextPage && !isFetching`.\n * @see {@link infiniteQueryOptions} to share these options between `useInfiniteQuery` and imperative APIs like `queryClient.infiniteQuery`.\n * @param options - An accessor returning the {@link DefinedInitialDataInfiniteOptions} to use — everything you\n * can pass to `useInfiniteQuery`, with `initialData` set.\n * @param queryClient - An accessor for a custom `QueryClient`. Otherwise, the one from the nearest context\n * will be used.\n * @returns The same properties as `useQuery`, with the addition of `fetchNextPage`, `fetchPreviousPage`,\n * `hasNextPage`, `hasPreviousPage`, `isFetchingNextPage`, and `isFetchingPreviousPage`. `data.pages` and\n * `data.pageParams` are also added, as long as a `select` doesn't change `TData` away from its default\n * `InfiniteData<TQueryFnData>` shape.\n *\n * @example\n * ```tsx\n * import { For } from 'solid-js'\n * import { useInfiniteQuery } from '@tanstack/solid-query'\n *\n * function Projects() {\n * // `projectsQuery.data` is never `undefined`, thanks to `initialData` — even if a refetch fails, so the\n * // list stays visible alongside the error.\n * const projectsQuery = useInfiniteQuery(() => ({\n * queryKey: ['projects'],\n * queryFn: ({ pageParam }) => fetchProjects(pageParam),\n * initialPageParam: 0,\n * getNextPageParam: (lastPage) => lastPage.nextId,\n * initialData: { pages: [], pageParams: [] },\n * }))\n *\n * return (\n * <div>\n * {projectsQuery.isError ? <span>Error: {projectsQuery.error.message}</span> : null}\n * <ul>\n * <For each={projectsQuery.data.pages}>\n * {(page) => <For each={page.projects}>{(p) => <li>{p.name}</li>}</For>}\n * </For>\n * </ul>\n * </div>\n * )\n * }\n * ```\n */\nexport function useInfiniteQuery<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: DefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n queryClient?: Accessor<QueryClient>,\n): DefinedUseInfiniteQueryResult<TData, TError>\n\n/**\n * The options for `useInfiniteQuery` are identical to `useQuery`, with the addition of\n * `initialPageParam`, `getNextPageParam`, `getPreviousPageParam`, and `maxPages`.\n *\n * @remarks Keep in mind that imperative fetch calls, such as `fetchNextPage`, may interfere with the default\n * refetch behavior, resulting in outdated data. Make sure to call these functions only in response to user\n * actions, or add conditions like `hasNextPage && !isFetching`.\n * @see {@link infiniteQueryOptions} to share these options between `useInfiniteQuery` and imperative APIs like `queryClient.infiniteQuery`.\n * @param options - An accessor returning the {@link UndefinedInitialDataInfiniteOptions} to use — everything\n * you can pass to `useInfiniteQuery`.\n * @param queryClient - An accessor for a custom `QueryClient`. Otherwise, the one from the nearest context\n * will be used.\n * @returns The same properties as `useQuery`, with the addition of `fetchNextPage`, `fetchPreviousPage`,\n * `hasNextPage`, `hasPreviousPage`, `isFetchingNextPage`, and `isFetchingPreviousPage`. `data.pages` and\n * `data.pageParams` are also added, as long as a `select` doesn't change `TData` away from its default\n * `InfiniteData<TQueryFnData>` shape.\n *\n * @example\n * Fetching the next page from a \"Load More\" button click:\n * ```tsx\n * import { For, Match, Switch } from 'solid-js'\n * import { useInfiniteQuery } from '@tanstack/solid-query'\n *\n * function Projects() {\n * const projectsQuery = useInfiniteQuery(() => ({\n * queryKey: ['projects'],\n * queryFn: ({ pageParam }) => fetchProjects(pageParam),\n * initialPageParam: 0,\n * getNextPageParam: (lastPage) => lastPage.nextId,\n * }))\n *\n * return (\n * <Switch>\n * <Match when={projectsQuery.isPending}>Loading...</Match>\n * <Match when={projectsQuery.isError}>Error: {projectsQuery.error.message}</Match>\n * <Match when={projectsQuery.isSuccess}>\n * <ul>\n * <For each={projectsQuery.data.pages}>\n * {(page) => <For each={page.projects}>{(p) => <li>{p.name}</li>}</For>}\n * </For>\n * </ul>\n * <button\n * onClick={() => projectsQuery.fetchNextPage()}\n * disabled={!projectsQuery.hasNextPage || projectsQuery.isFetching}\n * >\n * {projectsQuery.isFetchingNextPage\n * ? 'Loading more...'\n * : projectsQuery.hasNextPage\n * ? 'Load More'\n * : 'Nothing more to load'}\n * </button>\n * </Match>\n * </Switch>\n * )\n * }\n * ```\n *\n * @example\n * Fetching the next page automatically as the user scrolls, using an `IntersectionObserver` on a\n * sentinel element after the list:\n * ```tsx\n * import { For, Match, Switch, createEffect, onCleanup } from 'solid-js'\n * import { useInfiniteQuery } from '@tanstack/solid-query'\n *\n * function Projects() {\n * const projectsQuery = useInfiniteQuery(() => ({\n * queryKey: ['projects'],\n * queryFn: ({ pageParam }) => fetchProjects(pageParam),\n * initialPageParam: 0,\n * getNextPageParam: (lastPage) => lastPage.nextId,\n * }))\n *\n * let sentinelRef: HTMLDivElement | undefined\n *\n * createEffect(() => {\n * if (sentinelRef == null || !projectsQuery.hasNextPage || projectsQuery.isFetching) return\n *\n * const observer = new IntersectionObserver(([entry]) => {\n * if (entry?.isIntersecting) projectsQuery.fetchNextPage()\n * })\n * observer.observe(sentinelRef)\n *\n * onCleanup(() => observer.disconnect())\n * })\n *\n * return (\n * <Switch>\n * <Match when={projectsQuery.isPending}>Loading...</Match>\n * <Match when={projectsQuery.isError}>Error: {projectsQuery.error.message}</Match>\n * <Match when={projectsQuery.isSuccess}>\n * <ul>\n * <For each={projectsQuery.data.pages}>\n * {(page) => <For each={page.projects}>{(p) => <li>{p.name}</li>}</For>}\n * </For>\n * </ul>\n * <div ref={sentinelRef}>{projectsQuery.isFetchingNextPage ? 'Loading more...' : null}</div>\n * </Match>\n * </Switch>\n * )\n * }\n * ```\n */\nexport function useInfiniteQuery<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: UndefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n queryClient?: Accessor<QueryClient>,\n): UseInfiniteQueryResult<TData, TError>\n\nexport function useInfiniteQuery<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: UseInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n queryClient?: Accessor<QueryClient>,\n): UseInfiniteQueryResult<TData, TError> {\n return useBaseQuery(\n createMemo(() => options()),\n InfiniteQueryObserver as typeof QueryObserver,\n queryClient,\n ) as UseInfiniteQueryResult<TData, TError>\n}\n","import { MutationObserver, noop, shouldThrowError } from '@tanstack/query-core'\nimport { createComputed, createMemo, on, onCleanup } from 'solid-js'\nimport { createStore } from 'solid-js/store'\nimport { useQueryClientResolver } from './QueryClientProvider'\nimport type { DefaultError } from '@tanstack/query-core'\nimport type { QueryClient } from './QueryClient'\nimport type {\n UseMutateFunction,\n UseMutationOptions,\n UseMutationResult,\n} from './types'\nimport type { Accessor } from 'solid-js'\n\n/**\n * Unlike queries, mutations are typically used to create/update/delete data or perform server side-effects.\n * `useMutation` is the primitive for that.\n *\n * @param options - An accessor returning the {@link UseMutationOptions} to use.\n * @param queryClient - An accessor for a custom `QueryClient`. Otherwise, the one from the nearest context\n * will be used.\n * @returns `mutate`/`mutateAsync` also accept per-call `onSuccess`/`onError`/`onSettled` callbacks as a second\n * argument, useful for triggering call-site side effects (e.g. navigation) without coupling them to the shared\n * mutation definition. Hook-level callbacks (passed to `options`) fire for every mutation; per-call callbacks\n * fire only for the latest call you've made, and only while the component is still mounted — unmounting before\n * the mutation settles removes the subscription and prevents them from firing.\n *\n * @example\n * ```tsx\n * import { useMutation, useQueryClient } from '@tanstack/solid-query'\n *\n * function TodoItem(props: { id: number }) {\n * const queryClient = useQueryClient()\n *\n * const deleteTodoMutation = useMutation(() => ({\n * mutationFn: deleteTodo,\n * onSuccess: () => {\n * queryClient.invalidateQueries({ queryKey: ['todos'] })\n * },\n * }))\n *\n * return (\n * <button onClick={() => deleteTodoMutation.mutate({ id: props.id })} disabled={deleteTodoMutation.isPending}>\n * Delete\n * </button>\n * )\n * }\n * ```\n *\n * @example\n * Rendering the mutation's own state, rather than just firing it off:\n * ```tsx\n * import { Match, Switch } from 'solid-js'\n * import { useMutation, useQueryClient } from '@tanstack/solid-query'\n *\n * function AddTodo() {\n * const queryClient = useQueryClient()\n *\n * const addMutation = useMutation(() => ({\n * mutationFn: addTodo,\n * onSuccess: () => queryClient.invalidateQueries({ queryKey: ['todos'] }),\n * }))\n *\n * return (\n * <Switch fallback={<button onClick={() => addMutation.mutate('Item')}>Add</button>}>\n * <Match when={addMutation.isPending}>Adding todo...</Match>\n * <Match when={addMutation.isError}>\n * <div>An error occurred: {addMutation.error?.message}</div>\n * <button onClick={() => addMutation.mutate('Item')}>Add</button>\n * </Match>\n * </Switch>\n * )\n * }\n * ```\n *\n * @example\n * Optimistic update via `onMutate`, rolling back on `onError`:\n * ```tsx\n * import { useMutation, useQueryClient } from '@tanstack/solid-query'\n *\n * function AddTodo() {\n * const queryClient = useQueryClient()\n *\n * const addMutation = useMutation(() => ({\n * mutationFn: addTodo,\n * onMutate: async (newTodo) => {\n * await queryClient.cancelQueries({ queryKey: ['todos'] })\n * const previousTodos = queryClient.getQueryData<Array<string>>(['todos'])\n *\n * queryClient.setQueryData<Array<string>>(['todos'], (old) => [\n * ...(old ?? []),\n * newTodo,\n * ])\n *\n * // Passed to `onError` as `onMutateResult` if the mutation fails.\n * return { previousTodos }\n * },\n * onError: (_err, _newTodo, onMutateResult) => {\n * queryClient.setQueryData(['todos'], onMutateResult?.previousTodos)\n * },\n * onSettled: () => {\n * queryClient.invalidateQueries({ queryKey: ['todos'] })\n * },\n * }))\n *\n * return (\n * <button onClick={() => addMutation.mutate('Item')}>Add</button>\n * )\n * }\n * ```\n *\n * @example\n * Callbacks passed per call to `mutate` only fire for the last call — `mutateAsync` gives you a\n * promise per call instead, so you can wait for all of them when they succeed:\n * ```tsx\n * import { useMutation, useQueryClient } from '@tanstack/solid-query'\n *\n * function AddTodos() {\n * const queryClient = useQueryClient()\n *\n * const addMutation = useMutation(() => ({\n * mutationFn: addTodo,\n * onSuccess: () => queryClient.invalidateQueries({ queryKey: ['todos'] }),\n * }))\n *\n * async function handleAddAll(todos: Array<string>) {\n * try {\n * await Promise.all(todos.map((todo) => addMutation.mutateAsync(todo)))\n * } catch (error) {\n * console.error('Failed to add todos:', error)\n * }\n * }\n *\n * return (\n * <button onClick={() => handleAddAll(['Todo 1', 'Todo 2', 'Todo 3'])}>\n * Add all\n * </button>\n * )\n * }\n * ```\n *\n * @example\n * If some of the mutations above can fail independently of the others, and you want to know which ones\n * did — rather than losing that information the moment the first one rejects — swap `Promise.all` for\n * `Promise.allSettled`:\n * ```tsx\n * import { useMutation, useQueryClient } from '@tanstack/solid-query'\n *\n * function AddTodos() {\n * const queryClient = useQueryClient()\n *\n * const addMutation = useMutation(() => ({\n * mutationFn: addTodo,\n * onSuccess: () => queryClient.invalidateQueries({ queryKey: ['todos'] }),\n * }))\n *\n * async function handleAddAll(todos: Array<string>) {\n * const addResults = await Promise.allSettled(\n * todos.map((todo) => addMutation.mutateAsync(todo)),\n * )\n *\n * addResults.forEach((addResult, index) => {\n * if (addResult.status === 'rejected') {\n * console.error(`Failed to add \"${todos[index]}\":`, addResult.reason)\n * }\n * })\n * }\n *\n * return (\n * <button onClick={() => handleAddAll(['Todo 1', 'Todo 2', 'Todo 3'])}>\n * Add all\n * </button>\n * )\n * }\n * ```\n */\nexport function useMutation<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TOnMutateResult = unknown,\n>(\n options: UseMutationOptions<TData, TError, TVariables, TOnMutateResult>,\n queryClient?: Accessor<QueryClient>,\n): UseMutationResult<TData, TError, TVariables, TOnMutateResult> {\n const resolveClient = useQueryClientResolver(queryClient)\n const client = createMemo(() => resolveClient())\n\n const observer = new MutationObserver<\n TData,\n TError,\n TVariables,\n TOnMutateResult\n >(client(), options())\n\n const mutate: UseMutateFunction<\n TData,\n TError,\n TVariables,\n TOnMutateResult\n > = (...args) => {\n observer.mutate(args[0] as TVariables, args[1]).catch(noop)\n }\n\n const [state, setState] = createStore<\n UseMutationResult<TData, TError, TVariables, TOnMutateResult>\n >({\n ...observer.getCurrentResult(),\n mutate,\n mutateAsync: observer.getCurrentResult().mutate,\n })\n\n createComputed(() => {\n observer.setOptions(options())\n })\n\n createComputed(\n on(\n () => state.status,\n () => {\n if (\n state.isError &&\n shouldThrowError(observer.options.throwOnError, [state.error])\n ) {\n throw state.error\n }\n },\n ),\n )\n\n const unsubscribe = observer.subscribe((result) => {\n setState({\n ...result,\n mutate,\n mutateAsync: result.mutate,\n })\n })\n\n onCleanup(unsubscribe)\n\n return state\n}\n","import { QueriesObserver, noop } from '@tanstack/query-core'\nimport { createStore, unwrap } from 'solid-js/store'\nimport {\n batch,\n createComputed,\n createMemo,\n createRenderEffect,\n createResource,\n mergeProps,\n on,\n onCleanup,\n onMount,\n} from 'solid-js'\nimport { useQueryClientResolver } from './QueryClientProvider'\nimport { useIsRestoring } from './isRestoring'\nimport type { QueryOptions, UseQueryResult } from './types'\nimport type { Accessor } from 'solid-js'\nimport type { QueryClient } from './QueryClient'\nimport type {\n DefaultError,\n OmitKeyof,\n QueriesObserverOptions,\n QueriesPlaceholderDataFunction,\n QueryFunction,\n QueryKey,\n QueryObserverOptions,\n QueryObserverResult,\n ThrowOnError,\n} from '@tanstack/query-core'\n\n// This defines the `UseQueryOptions` that are accepted in `QueriesOptions` & `GetOptions`.\n// `placeholderData` function does not have a parameter\ntype UseQueryOptionsForUseQueries<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> = OmitKeyof<\n QueryOptions<TQueryFnData, TError, TData, TQueryKey>,\n 'placeholderData' | 'suspense'\n> & {\n placeholderData?: TQueryFnData | QueriesPlaceholderDataFunction<TQueryFnData>\n /**\n * @deprecated The `suspense` option has been deprecated in v5 and will be removed in the next major version.\n * The `data` property on useQueries is a plain object and not a SolidJS Resource.\n * It will not suspend when the data is loading.\n * Setting `suspense` to `true` will be a no-op.\n */\n suspense?: boolean\n}\n\n// Avoid TS depth-limit error in case of large array literal\ntype MAXIMUM_DEPTH = 20\n\n// Widen the type of the symbol to enable type inference even if skipToken is not immutable.\ntype SkipTokenForUseQueries = symbol\n\ntype GetOptions<T> =\n // Part 1: responsible for applying explicit type parameter to function arguments, if object { queryFnData: TQueryFnData, error: TError, data: TData }\n T extends {\n queryFnData: infer TQueryFnData\n error?: infer TError\n data: infer TData\n }\n ? UseQueryOptionsForUseQueries<TQueryFnData, TError, TData>\n : T extends { queryFnData: infer TQueryFnData; error?: infer TError }\n ? UseQueryOptionsForUseQueries<TQueryFnData, TError>\n : T extends { data: infer TData; error?: infer TError }\n ? UseQueryOptionsForUseQueries<unknown, TError, TData>\n : // Part 2: responsible for applying explicit type parameter to function arguments, if tuple [TQueryFnData, TError, TData]\n T extends [infer TQueryFnData, infer TError, infer TData]\n ? UseQueryOptionsForUseQueries<TQueryFnData, TError, TData>\n : T extends [infer TQueryFnData, infer TError]\n ? UseQueryOptionsForUseQueries<TQueryFnData, TError>\n : T extends [infer TQueryFnData]\n ? UseQueryOptionsForUseQueries<TQueryFnData>\n : // Part 3: responsible for inferring and enforcing type if no explicit parameter was provided\n T extends {\n queryFn?:\n | QueryFunction<infer TQueryFnData, infer TQueryKey>\n | SkipTokenForUseQueries\n select?: (data: any) => infer TData\n throwOnError?: ThrowOnError<any, infer TError, any, any>\n }\n ? UseQueryOptionsForUseQueries<\n TQueryFnData,\n unknown extends TError ? DefaultError : TError,\n unknown extends TData ? TQueryFnData : TData,\n TQueryKey\n >\n : // Fallback\n UseQueryOptionsForUseQueries\n\ntype GetResults<T> =\n // Part 1: responsible for mapping explicit type parameter to function result, if object\n T extends { queryFnData: any; error?: infer TError; data: infer TData }\n ? UseQueryResult<TData, TError>\n : T extends { queryFnData: infer TQueryFnData; error?: infer TError }\n ? UseQueryResult<TQueryFnData, TError>\n : T extends { data: infer TData; error?: infer TError }\n ? UseQueryResult<TData, TError>\n : // Part 2: responsible for mapping explicit type parameter to function result, if tuple\n T extends [any, infer TError, infer TData]\n ? UseQueryResult<TData, TError>\n : T extends [infer TQueryFnData, infer TError]\n ? UseQueryResult<TQueryFnData, TError>\n : T extends [infer TQueryFnData]\n ? UseQueryResult<TQueryFnData>\n : // Part 3: responsible for mapping inferred type to results, if no explicit parameter was provided\n T extends {\n queryFn?:\n | QueryFunction<infer TQueryFnData, any>\n | SkipTokenForUseQueries\n select?: (data: any) => infer TData\n throwOnError?: ThrowOnError<any, infer TError, any, any>\n }\n ? UseQueryResult<\n unknown extends TData ? TQueryFnData : TData,\n unknown extends TError ? DefaultError : TError\n >\n : // Fallback\n UseQueryResult\n\n/**\n * QueriesOptions reducer recursively unwraps function arguments to infer/enforce type param\n */\ntype QueriesOptions<\n T extends Array<any>,\n TResult extends Array<any> = [],\n TDepth extends ReadonlyArray<number> = [],\n> = TDepth['length'] extends MAXIMUM_DEPTH\n ? Array<UseQueryOptionsForUseQueries>\n : T extends []\n ? []\n : T extends [infer Head]\n ? [...TResult, GetOptions<Head>]\n : T extends [infer Head, ...infer Tail]\n ? QueriesOptions<\n [...Tail],\n [...TResult, GetOptions<Head>],\n [...TDepth, 1]\n >\n : ReadonlyArray<unknown> extends T\n ? T\n : // If T is *some* array but we couldn't assign unknown[] to it, then it must hold some known/homogeneous type!\n // use this to infer the param types in the case of Array.map() argument\n T extends Array<\n UseQueryOptionsForUseQueries<\n infer TQueryFnData,\n infer TError,\n infer TData,\n infer TQueryKey\n >\n >\n ? Array<\n UseQueryOptionsForUseQueries<\n TQueryFnData,\n TError,\n TData,\n TQueryKey\n >\n >\n : // Fallback\n Array<UseQueryOptionsForUseQueries>\n\n/**\n * QueriesResults reducer recursively maps type param to results\n */\ntype QueriesResults<\n T extends Array<any>,\n TResult extends Array<any> = [],\n TDepth extends ReadonlyArray<number> = [],\n> = TDepth['length'] extends MAXIMUM_DEPTH\n ? Array<UseQueryResult>\n : T extends []\n ? []\n : T extends [infer Head]\n ? [...TResult, GetResults<Head>]\n : T extends [infer Head, ...infer Tail]\n ? QueriesResults<\n [...Tail],\n [...TResult, GetResults<Head>],\n [...TDepth, 1]\n >\n : { [K in keyof T]: GetResults<T[K]> }\n\n/**\n * The `useQueries` primitive can be used to fetch a variable number of queries.\n *\n * The `queries` key accepts an array with query option objects mostly identical to `useQuery` — see\n * `placeholderData` below for the one difference. A custom `QueryClient` is supplied once, as `useQueries`'\n * own top-level second argument, rather than per query.\n *\n * Having the same query key more than once in the array of query objects may cause some data to be shared\n * between queries. To avoid this, consider de-duplicating the queries and map the results back to the desired\n * structure.\n *\n * The `combine` option can be used to combine the results of the queries into a single value. The result will\n * be structurally shared to be as referentially stable as possible.\n *\n * `placeholderData` is supported here too, but unlike `useQuery`, it doesn't receive information from\n * previously rendered queries, because the number of queries can differ between renders.\n * @param queriesOptions - An accessor returning the `queries` array to run, and an optional `combine`\n * function.\n * @param queryClient - An accessor for a custom `QueryClient`. Otherwise, the one from the nearest context\n * will be used.\n * @returns The combined result. Without `combine`, this is an array with all the query results, in the same\n * order as the input. When `combine` is provided, this is the value returned by `combine` instead.\n *\n * @example\n * ```tsx\n * import { For } from 'solid-js'\n * import { useQueries } from '@tanstack/solid-query'\n *\n * function Posts(props: { ids: Array<number> }) {\n * const postQueries = useQueries(() => ({\n * queries: props.ids.map((id) => ({\n * queryKey: ['post', id],\n * queryFn: () => fetchPost(id),\n * staleTime: Infinity,\n * })),\n * }))\n *\n * return (\n * <ul>\n * <For each={postQueries}>\n * {(postQuery) => {\n * if (postQuery.isPending) return <li>Loading...</li>\n * if (postQuery.isError) return <li>Error: {postQuery.error.message}</li>\n * return <li>{postQuery.data.title}</li>\n * }}\n * </For>\n * </ul>\n * )\n * }\n * ```\n *\n * @example\n * Combining results into a single value:\n * ```tsx\n * import { For, Match, Switch } from 'solid-js'\n * import { useQueries } from '@tanstack/solid-query'\n *\n * function Posts(props: { ids: Array<number> }) {\n * const combinedPostsQuery = useQueries(() => ({\n * queries: props.ids.map((id) => ({\n * queryKey: ['post', id],\n * queryFn: () => fetchPost(id),\n * })),\n * combine: (postQueries) => {\n * return {\n * data: postQueries.map((postQuery) => postQuery.data),\n * isPending: postQueries.some((postQuery) => postQuery.isPending),\n * isError: postQueries.some((postQuery) => postQuery.isError),\n * }\n * },\n * }))\n *\n * return (\n * <Switch\n * fallback={\n * <ul>\n * <For each={combinedPostsQuery.data}>{(post) => <li>{post?.title}</li>}</For>\n * </ul>\n * }\n * >\n * <Match when={combinedPostsQuery.isPending}>Loading...</Match>\n * <Match when={combinedPostsQuery.isError}>Error loading posts</Match>\n * </Switch>\n * )\n * }\n * ```\n */\nexport function useQueries<\n T extends Array<any>,\n TCombinedResult extends QueriesResults<T> = QueriesResults<T>,\n>(\n queriesOptions: Accessor<{\n queries:\n | readonly [...QueriesOptions<T>]\n | readonly [...{ [K in keyof T]: GetOptions<T[K]> }]\n combine?: (result: QueriesResults<T>) => TCombinedResult\n }>,\n queryClient?: Accessor<QueryClient>,\n): TCombinedResult {\n const resolveClient = useQueryClientResolver(queryClient)\n const client = createMemo(() => resolveClient())\n const isRestoring = useIsRestoring()\n\n const defaultedQueries = createMemo(() =>\n queriesOptions().queries.map((options) =>\n mergeProps(\n client().defaultQueryOptions(options as QueryObserverOptions),\n {\n get _optimisticResults() {\n return isRestoring() ? 'isRestoring' : 'optimistic'\n },\n },\n ),\n ),\n )\n\n const observer = new QueriesObserver(\n client(),\n defaultedQueries(),\n queriesOptions().combine\n ? ({\n combine: queriesOptions().combine,\n } as QueriesObserverOptions<TCombinedResult>)\n : undefined,\n )\n\n const [state, setState] = createStore<TCombinedResult>(\n observer.getOptimisticResult(\n defaultedQueries(),\n (queriesOptions() as QueriesObserverOptions<TCombinedResult>).combine,\n )[1](),\n )\n\n createRenderEffect(\n on(\n () => queriesOptions().queries.length,\n () =>\n setState(\n observer.getOptimisticResult(\n defaultedQueries(),\n (queriesOptions() as QueriesObserverOptions<TCombinedResult>)\n .combine,\n )[1](),\n ),\n ),\n )\n\n const dataResources = createMemo(\n on(\n () => state.length,\n () =>\n state.map((queryRes) => {\n const dataPromise = () =>\n new Promise((resolve) => {\n if (queryRes.isFetching && queryRes.isLoading) return\n resolve(unwrap(queryRes.data))\n })\n return createResource(dataPromise)\n }),\n ),\n )\n\n batch(() => {\n const dataResources_ = dataResources()\n for (let index = 0; index < dataResources_.length; index++) {\n const dataResource = dataResources_[index]!\n dataResource[1].mutate(() => unwrap(state[index]!.data))\n dataResource[1].refetch()\n }\n })\n\n let taskQueue: Array<() => void> = []\n const subscribeToObserver = () =>\n observer.subscribe((result) => {\n taskQueue.push(() => {\n batch(() => {\n const dataResources_ = dataResources()\n for (let index = 0; index < dataResources_.length; index++) {\n const dataResource = dataResources_[index]!\n const unwrappedResult = { ...unwrap(result[index]) }\n // @ts-expect-error typescript pedantry regarding the possible range of index\n setState(index, unwrap(unwrappedResult))\n dataResource[1].mutate(() => unwrap(state[index]!.data))\n dataResource[1].refetch()\n }\n })\n })\n\n queueMicrotask(() => {\n const taskToRun = taskQueue.pop()\n if (taskToRun) taskToRun()\n taskQueue = []\n })\n })\n\n let unsubscribe: () => void = noop\n createComputed<() => void>((cleanup) => {\n cleanup?.()\n unsubscribe = isRestoring() ? noop : subscribeToObserver()\n // cleanup needs to be scheduled after synchronous effects take place\n return () => queueMicrotask(unsubscribe)\n })\n onCleanup(unsubscribe)\n\n onMount(() => {\n observer.setQueries(\n defaultedQueries(),\n queriesOptions().combine\n ? ({\n combine: queriesOptions().combine,\n } as QueriesObserverOptions<TCombinedResult>)\n : undefined,\n )\n })\n\n createComputed(() => {\n observer.setQueries(\n defaultedQueries(),\n queriesOptions().combine\n ? ({\n combine: queriesOptions().combine,\n } as QueriesObserverOptions<TCombinedResult>)\n : undefined,\n )\n })\n\n const handler = (index: number) => ({\n get(target: QueryObserverResult, prop: keyof QueryObserverResult): any {\n if (prop === 'data') {\n return dataResources()[index]![0]()\n }\n return Reflect.get(target, prop)\n },\n })\n\n const getProxies = () =>\n state.map((s, index) => {\n return new Proxy(s, handler(index))\n })\n\n const [proxyState, setProxyState] = createStore(getProxies())\n createRenderEffect(() => setProxyState(getProxies()))\n\n return proxyState as TCombinedResult\n}\n","import { QueryClient as QueryCoreClient } from '@tanstack/query-core'\nimport type {\n DefaultOptions as CoreDefaultOptions,\n DefaultError,\n OmitKeyof,\n QueryClientConfig as QueryCoreClientConfig,\n InfiniteQueryObserverOptions as QueryCoreInfiniteQueryObserverOptions,\n QueryObserverOptions as QueryCoreObserverOptions,\n QueryKey,\n} from '@tanstack/query-core'\n\n/**\n * The core `QueryObserverOptions`, with Solid's `reconcile` option added.\n *\n * @template TQueryFnData - The type your `queryFn` resolves to.\n * @template TError - The type of errors your `queryFn` may throw.\n * @template TData - The type `data` ends up as after `select` runs.\n * @template TQueryData - The type of the data actually held in the query cache.\n * @template TQueryKey - The type of your `queryKey`.\n * @template TPageParam - The type of the parameter passed to `queryFn` to fetch a given page, when this type\n * is shared with an infinite query's observer options. Defaults to `never` for regular queries.\n */\nexport interface QueryObserverOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = never,\n> extends OmitKeyof<\n QueryCoreObserverOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey,\n TPageParam\n >,\n 'structuralSharing'\n> {\n /**\n * Set this to a reconciliation key to enable reconciliation between query results.\n * Set this to `false` to disable reconciliation between query results.\n * Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom reconciliation logic.\n * Defaults reconciliation to false.\n */\n reconcile?:\n string | false | ((oldData: TData | undefined, newData: TData) => TData)\n}\n\n/**\n * The core `InfiniteQueryObserverOptions`, with Solid's `reconcile` option added.\n *\n * @template TQueryFnData - The type of a single page, as your `queryFn` resolves it.\n * @template TError - The type of errors your `queryFn` may throw.\n * @template TData - The type `data` ends up as after `select` runs.\n * @template TQueryKey - The type of your `queryKey`.\n * @template TPageParam - The type of the parameter passed to `queryFn` to fetch a given page.\n */\nexport interface InfiniteQueryObserverOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n> extends OmitKeyof<\n QueryCoreInfiniteQueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n 'structuralSharing'\n> {\n /**\n * Set this to a reconciliation key to enable reconciliation between query results.\n * Set this to `false` to disable reconciliation between query results.\n * Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom reconciliation logic.\n * Defaults reconciliation to false.\n */\n reconcile?:\n string | false | ((oldData: TData | undefined, newData: TData) => TData)\n}\n\n/**\n * The default options a `QueryClient` applies to every query, with Solid's `reconcile` option added to\n * `queries`.\n *\n * @template TError - The default type of errors thrown by queries and mutations using this `QueryClient`.\n */\nexport interface DefaultOptions<\n TError = DefaultError,\n> extends CoreDefaultOptions<TError> {\n queries?: OmitKeyof<QueryObserverOptions<unknown, TError>, 'queryKey'>\n}\n\n/**\n * The config accepted by `new QueryClient(config)`, with Solid's extended {@link DefaultOptions}.\n */\nexport interface QueryClientConfig extends QueryCoreClientConfig {\n defaultOptions?: DefaultOptions\n}\n\n/**\n * The core `@tanstack/query-core` `QueryClient`, typed so its `defaultOptions.queries` accepts Solid's\n * `reconcile` option.\n */\nexport class QueryClient extends QueryCoreClient {\n constructor(config: QueryClientConfig = {}) {\n super(config)\n }\n}\n","import type {\n DefaultError,\n QueryKey,\n QueryKeyWithDataTag,\n} from '@tanstack/query-core'\nimport type { QueryOptions } from './types'\nimport type { Accessor } from 'solid-js'\n\n/**\n * The options accepted by the `queryOptions` overload selected when no `initialData` is set — `data` may be\n * `undefined` while the query is `pending`. `queryOptions` itself accepts and returns a plain object (its\n * parameter type is `ReturnType<UndefinedInitialDataOptions<...>>`, i.e. this `Accessor` called); Solid's\n * reactivity applies where the result is consumed instead, e.g. `useQuery(() => options)`.\n *\n * @template TQueryFnData - The type your `queryFn` resolves to.\n * @template TError - The type of errors your `queryFn` may throw.\n * @template TData - The type `data` ends up as after `select` runs.\n * @template TQueryKey - The type of your `queryKey`.\n */\nexport type UndefinedInitialDataOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> = Accessor<\n QueryOptions<TQueryFnData, TError, TData, TQueryKey> & {\n initialData?: undefined\n }\n>\n\n/**\n * The options accepted by the `queryOptions` overload selected when `initialData` is set — `data` is never\n * `undefined` (unless a `select` changes `TData` to include `undefined`).\n *\n * @template TQueryFnData - The type your `queryFn` resolves to.\n * @template TError - The type of errors your `queryFn` may throw.\n * @template TData - The type `data` ends up as after `select` runs.\n * @template TQueryKey - The type of your `queryKey`.\n */\nexport type DefinedInitialDataOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> = Accessor<\n QueryOptions<TQueryFnData, TError, TData, TQueryKey> & {\n initialData: TQueryFnData | (() => TQueryFnData)\n }\n>\n\n/**\n * You can generally pass everything to `queryOptions` that you can also pass to `useQuery`. These options can\n * be shared across hooks and imperative APIs such as `queryClient.query`. `options.queryKey` is required and\n * is the query key to generate options for.\n *\n * This overload is selected when `initialData` is set, so the resulting `data` is never `undefined` (unless\n * a `select` changes `TData` to include `undefined`).\n *\n * @see {@link useQuery} to run a query with these options.\n * @param options - The {@link DefinedInitialDataOptions} to use — everything you can pass to `useQuery`, with `initialData` set.\n * @returns The same options object, typed so that `queryKey` carries the inferred data type.\n *\n * @example\n * ```tsx\n * import { For } from 'solid-js'\n * import { queryOptions, useQuery } from '@tanstack/solid-query'\n *\n * const postsOptions = queryOptions({\n * queryKey: ['posts'],\n * queryFn: fetchPosts,\n * initialData: [],\n * })\n *\n * function Posts() {\n * // `postsQuery.data` is `Post[]`, never `undefined`, thanks to `initialData` — even if a refetch fails,\n * // so the list stays visible alongside the error.\n * const postsQuery = useQuery(() => postsOptions)\n *\n * return (\n * <div>\n * {postsQuery.isError ? <span>Error: {postsQuery.error.message}</span> : null}\n * <ul>\n * <For each={postsQuery.data}>{(post) => <li>{post.title}</li>}</For>\n * </ul>\n * </div>\n * )\n * }\n * ```\n */\nexport function queryOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: ReturnType<\n DefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>\n >,\n): ReturnType<\n DefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>\n> &\n QueryKeyWithDataTag<TQueryKey, TQueryFnData, TError>\n\n/**\n * You can generally pass everything to `queryOptions` that you can also pass to `useQuery`. These options can\n * be shared across hooks and imperative APIs such as `queryClient.query`. `options.queryKey` is required and\n * is the query key to generate options for.\n *\n * @see {@link useQuery} to run a query with these options.\n * @param options - The {@link UndefinedInitialDataOptions} to use — everything you can pass to `useQuery`.\n * @returns The same options object, typed so that `queryKey` carries the inferred data type.\n *\n * @example\n * A parameterized factory, so the same options object can be reused per `id`:\n * ```tsx\n * import { Match, Switch } from 'solid-js'\n * import { queryOptions, useQuery } from '@tanstack/solid-query'\n *\n * const postOptions = (id: string) =>\n * queryOptions({\n * queryKey: ['post', id],\n * queryFn: () => fetchPost(id),\n * })\n *\n * function Post(props: { id: string }) {\n * const postQuery = useQuery(() => postOptions(props.id))\n *\n * return (\n * <Switch>\n * <Match when={postQuery.isPending}>Loading...</Match>\n * <Match when={postQuery.isError}>Error: {postQuery.error.message}</Match>\n * <Match when={postQuery.isSuccess}>\n * <h1>{postQuery.data.title}</h1>\n * </Match>\n * </Switch>\n * )\n * }\n * ```\n */\nexport function queryOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: ReturnType<\n UndefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>\n >,\n): ReturnType<\n UndefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>\n> &\n QueryKeyWithDataTag<TQueryKey, TQueryFnData, TError>\n\nexport function queryOptions(options: unknown) {\n return options\n}\n","import { createEffect, createMemo, createSignal, onCleanup } from 'solid-js'\nimport { useQueryClientResolver } from './QueryClientProvider'\nimport type { QueryFilters } from '@tanstack/query-core'\nimport type { QueryClient } from './QueryClient'\nimport type { Accessor } from 'solid-js'\n\n/**\n * The `useIsFetching` primitive returns the `number` of the queries that your application is loading or fetching\n * in the background (useful for app-wide loading indicators).\n *\n * @param filters - An accessor returning the {@link QueryFilters} to narrow down the matched queries.\n * @param queryClient - An accessor for a custom `QueryClient`. Otherwise, the one from the nearest context\n * will be used.\n * @returns An accessor for the `number` of the queries that your application is currently loading or fetching\n * in the background.\n *\n * @example\n * ```tsx\n * import { useIsFetching } from '@tanstack/solid-query'\n *\n * function GlobalLoadingIndicator() {\n * // How many queries matching the posts prefix are fetching?\n * const isFetchingPosts = useIsFetching(() => ({ queryKey: ['posts'] }))\n *\n * return isFetchingPosts() > 0 ? <span>Loading posts...</span> : null\n * }\n * ```\n */\nexport function useIsFetching(\n filters?: Accessor<QueryFilters>,\n queryClient?: Accessor<QueryClient>,\n): Accessor<number> {\n const resolveClient = useQueryClientResolver(queryClient)\n const client = createMemo(() => resolveClient())\n const queryCache = createMemo(() => client().getQueryCache())\n\n const [fetches, setFetches] = createSignal(client().isFetching(filters?.()))\n\n createEffect(() => {\n setFetches(client().isFetching(filters?.()))\n\n const unsubscribe = queryCache().subscribe(() => {\n setFetches(client().isFetching(filters?.()))\n })\n\n onCleanup(unsubscribe)\n })\n\n return fetches\n}\n","import type {\n DefaultError,\n InfiniteData,\n NonUndefinedGuard,\n QueryKey,\n QueryKeyWithDataTag,\n} from '@tanstack/query-core'\nimport type { InfiniteQueryOptions } from './types'\nimport type { Accessor } from 'solid-js'\n\n/**\n * The options accepted by the `infiniteQueryOptions` overload selected when no `initialData` is set — `data`\n * may be `undefined` while the query is `pending`. `infiniteQueryOptions` itself accepts and returns a plain\n * object (its parameter type is `ReturnType<UndefinedInitialDataInfiniteOptions<...>>`, i.e. this `Accessor`\n * called); Solid's reactivity applies where the result is consumed instead, e.g.\n * `useInfiniteQuery(() => options)`.\n *\n * @template TQueryFnData - The type of a single page, as your `queryFn` resolves it.\n * @template TError - The type of errors your `queryFn` may throw.\n * @template TData - The type `data` ends up as after `select` runs — defaults to `InfiniteData<TQueryFnData>`,\n * the shape of all fetched pages plus their page params.\n * @template TQueryKey - The type of your `queryKey`.\n * @template TPageParam - The type of the parameter passed to `queryFn` to fetch a given page.\n */\nexport type UndefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n> = Accessor<\n InfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam> & {\n initialData?: undefined\n }\n>\n\n/**\n * The options accepted by the `infiniteQueryOptions` overload selected when `initialData` is set — `data` is\n * never `undefined` (unless a `select` changes `TData` to include `undefined`).\n *\n * @template TQueryFnData - The type of a single page, as your `queryFn` resolves it.\n * @template TError - The type of errors your `queryFn` may throw.\n * @template TData - The type `data` ends up as after `select` runs — defaults to `InfiniteData<TQueryFnData>`,\n * the shape of all fetched pages plus their page params.\n * @template TQueryKey - The type of your `queryKey`.\n * @template TPageParam - The type of the parameter passed to `queryFn` to fetch a given page.\n */\nexport type DefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError = DefaultError,\n // should we handle page param correctly\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n> = Accessor<\n InfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam> & {\n initialData:\n | NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>\n | (() => NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>)\n }\n>\n\n/**\n * You can generally pass everything to `infiniteQueryOptions` that you can also pass to `useInfiniteQuery`.\n * These options can be shared across hooks and imperative APIs such as `queryClient.infiniteQuery`.\n * `options.queryKey` is required and is the query key to generate options for.\n *\n * This overload is selected when `initialData` is set.\n *\n * @see {@link useInfiniteQuery} to run an infinite query with these options.\n * @param options - The {@link DefinedInitialDataInfiniteOptions} to use — everything you can pass to `useInfiniteQuery`, with `initialData` set.\n * @returns The same options object, typed so that `queryKey` carries the inferred data type.\n *\n * @example\n * ```tsx\n * import { For } from 'solid-js'\n * import { infiniteQueryOptions, useInfiniteQuery } from '@tanstack/solid-query'\n *\n * const projectsOptions = infiniteQueryOptions({\n * queryKey: ['projects'],\n * queryFn: ({ pageParam }) => fetchProjects(pageParam),\n * initialPageParam: 0,\n * getNextPageParam: (lastPage) => lastPage.nextId,\n * initialData: { pages: [], pageParams: [] },\n * })\n *\n * function Projects() {\n * // `projectsQuery.data` is never `undefined`, thanks to `initialData` — even if a refetch fails, so the\n * // list stays visible alongside the error.\n * const projectsQuery = useInfiniteQuery(() => projectsOptions)\n *\n * return (\n * <div>\n * {projectsQuery.isError ? <span>Error: {projectsQuery.error.message}</span> : null}\n * <ul>\n * <For each={projectsQuery.data.pages}>\n * {(page) => <For each={page.projects}>{(p) => <li>{p.name}</li>}</For>}\n * </For>\n * </ul>\n * </div>\n * )\n * }\n * ```\n */\nexport function infiniteQueryOptions<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: ReturnType<\n DefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >\n >,\n): ReturnType<\n DefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >\n> &\n QueryKeyWithDataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>\n\n/**\n * You can generally pass everything to `infiniteQueryOptions` that you can also pass to `useInfiniteQuery`.\n * These options can be shared across hooks and imperative APIs such as `queryClient.infiniteQuery`.\n * `options.queryKey` is required and is the query key to generate options for.\n *\n * @see {@link useInfiniteQuery} to run an infinite query with these options.\n * @param options - The {@link UndefinedInitialDataInfiniteOptions} to use — everything you can pass to `useInfiniteQuery`.\n * @returns The same options object, typed so that `queryKey` carries the inferred data type.\n *\n * @example\n * A parameterized factory, so the same options object can be reused per `postId`:\n * ```tsx\n * import { For, Match, Switch } from 'solid-js'\n * import { infiniteQueryOptions, useInfiniteQuery } from '@tanstack/solid-query'\n *\n * const commentsOptions = (postId: string) =>\n * infiniteQueryOptions({\n * queryKey: ['post', postId, 'comments'],\n * queryFn: ({ pageParam }) => fetchComments(postId, pageParam),\n * initialPageParam: 0,\n * getNextPageParam: (lastPage) => lastPage.nextId,\n * })\n *\n * function Comments(props: { postId: string }) {\n * const commentsQuery = useInfiniteQuery(() => commentsOptions(props.postId))\n *\n * return (\n * <Switch>\n * <Match when={commentsQuery.isPending}>Loading...</Match>\n * <Match when={commentsQuery.isError}>Error: {commentsQuery.error.message}</Match>\n * <Match when={commentsQuery.isSuccess}>\n * <ul>\n * <For each={commentsQuery.data.pages}>\n * {(page) => <For each={page.comments}>{(c) => <li>{c.text}</li>}</For>}\n * </For>\n * </ul>\n * </Match>\n * </Switch>\n * )\n * }\n * ```\n */\nexport function infiniteQueryOptions<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: ReturnType<\n UndefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >\n >,\n): ReturnType<\n UndefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >\n> &\n QueryKeyWithDataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>\n\nexport function infiniteQueryOptions(options: unknown) {\n return options\n}\n","import type { DefaultError, WithRequired } from '@tanstack/query-core'\nimport type { MutationOptions } from './types'\n\n/**\n * You can generally pass everything to `mutationOptions` that you can also pass to `useMutation`. A\n * `mutationKey` is required on this overload so the mutation can be looked up later, e.g. with\n * `useMutationState`.\n *\n * @see {@link useMutation} to run the mutation these options describe.\n * @param options - The mutation options to use, identical to what you'd pass to `useMutation`, with a\n * required `mutationKey`.\n * @returns The same options object, unchanged.\n *\n * @example\n * Looking the mutation up elsewhere via its `mutationKey`, e.g. for a global \"saving…\" indicator:\n * ```tsx\n * import { mutationOptions, useMutationState } from '@tanstack/solid-query'\n *\n * const createPostOptions = mutationOptions({\n * mutationKey: ['posts', 'create'],\n * mutationFn: createPost,\n * })\n *\n * function SavingIndicator() {\n * const isCreatingPost = useMutationState(() => ({\n * filters: { mutationKey: createPostOptions.mutationKey, status: 'pending' },\n * }))\n *\n * return isCreatingPost().length > 0 ? <span>Saving…</span> : null\n * }\n * ```\n */\nexport function mutationOptions<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TOnMutateResult = unknown,\n>(\n options: WithRequired<\n MutationOptions<TData, TError, TVariables, TOnMutateResult>,\n 'mutationKey'\n >,\n): WithRequired<\n MutationOptions<TData, TError, TVariables, TOnMutateResult>,\n 'mutationKey'\n>\n/**\n * You can generally pass everything to `mutationOptions` that you can also pass to `useMutation`. No\n * `mutationKey` is required on this overload — use this when you don't need to target the mutation via a\n * `mutationKey` filter later (e.g. with `useMutationState`); it can still be observed through other filters,\n * such as `status`.\n *\n * @see {@link useMutation} to run the mutation these options describe.\n * @param options - The mutation options to use, identical to what you'd pass to `useMutation`, without a\n * `mutationKey`.\n * @returns The same options object, unchanged.\n * @remarks See the other overload's example for looking a mutation up via `useMutationState`.\n *\n * @example\n * ```tsx\n * import { mutationOptions, useMutation } from '@tanstack/solid-query'\n *\n * const createPostOptions = mutationOptions({\n * mutationFn: createPost,\n * })\n *\n * function CreatePost() {\n * const createPostMutation = useMutation(() => createPostOptions)\n * return <button onClick={() => createPostMutation.mutate({ title: 'Hello' })}>Create</button>\n * }\n * ```\n */\nexport function mutationOptions<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TOnMutateResult = unknown,\n>(\n options: Omit<\n MutationOptions<TData, TError, TVariables, TOnMutateResult>,\n 'mutationKey'\n >,\n): Omit<\n MutationOptions<TData, TError, TVariables, TOnMutateResult>,\n 'mutationKey'\n>\nexport function mutationOptions<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TOnMutateResult = unknown,\n>(\n options: MutationOptions<TData, TError, TVariables, TOnMutateResult>,\n): MutationOptions<TData, TError, TVariables, TOnMutateResult> {\n return options\n}\n","import { createEffect, createMemo, createSignal, onCleanup } from 'solid-js'\nimport { useQueryClientResolver } from './QueryClientProvider'\nimport type { MutationFilters } from '@tanstack/query-core'\nimport type { QueryClient } from './QueryClient'\nimport type { Accessor } from 'solid-js'\n\n/**\n * The `useIsMutating` primitive returns the `number` of mutations that your application currently has `pending`\n * (useful for app-wide loading indicators).\n *\n * @param filters - An accessor returning the {@link MutationFilters} to narrow down the matched mutations.\n * @param queryClient - An accessor for a custom `QueryClient`. Otherwise, the one from the nearest context\n * will be used.\n * @returns An accessor for the `number` of the mutations that your application currently has `pending`.\n *\n * @example\n * ```tsx\n * import { useIsMutating } from '@tanstack/solid-query'\n *\n * function PostsMutatingIndicator() {\n * // How many mutations matching the posts prefix are in progress?\n * const isMutatingPosts = useIsMutating(() => ({ mutationKey: ['posts'] }))\n *\n * return isMutatingPosts() > 0 ? <span>Saving posts...</span> : null\n * }\n * ```\n */\nexport function useIsMutating(\n filters?: Accessor<MutationFilters>,\n queryClient?: Accessor<QueryClient>,\n): Accessor<number> {\n const resolveClient = useQueryClientResolver(queryClient)\n const client = createMemo(() => resolveClient())\n const mutationCache = createMemo(() => client().getMutationCache())\n\n const [mutations, setMutations] = createSignal(\n client().isMutating(filters?.()),\n )\n\n createEffect(() => {\n setMutations(client().isMutating(filters?.()))\n\n const unsubscribe = mutationCache().subscribe(() => {\n setMutations(client().isMutating(filters?.()))\n })\n\n onCleanup(unsubscribe)\n })\n\n return mutations\n}\n","import { createEffect, createMemo, createSignal, onCleanup } from 'solid-js'\nimport { replaceEqualDeep } from '@tanstack/query-core'\nimport { useQueryClientResolver } from './QueryClientProvider'\nimport type {\n Mutation,\n MutationCache,\n MutationFilters,\n MutationState,\n} from '@tanstack/query-core'\nimport type { Accessor } from 'solid-js'\nimport type { QueryClient } from './QueryClient'\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\ntype MutationStateOptions<\n TResult = MutationState,\n TMutation extends Mutation<any, any, any, any> =\n MutationTypeFromResult<TResult>,\n> = {\n filters?: MutationFilters\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 primitive that gives you access to all mutations in the `MutationCache`. You can pass\n * `filters` ({@link MutationFilters}) to narrow down your mutations, and `select` to transform the mutation\n * state.\n *\n * @param options - An accessor returning the `filters` to narrow down matched mutations, and an optional\n * `select` to transform the mutation state.\n * @param queryClient - An accessor for a custom `QueryClient`. Otherwise, the one from the nearest context\n * will be used.\n * @returns An accessor for an array of whatever `select` returns for each matching mutation.\n *\n * @example\n * Get all variables of all running mutations:\n * ```tsx\n * import { useMutationState } from '@tanstack/solid-query'\n *\n * function PendingPosts() {\n * const pendingVariables = useMutationState(() => ({\n * filters: { status: 'pending' },\n * select: (mutation) => mutation.state.variables,\n * }))\n *\n * return <>{pendingVariables().length} posts saving...</>\n * }\n * ```\n *\n * @example\n * Get all data for specific mutations via the `mutationKey`:\n * ```tsx\n * import { useMutation, useMutationState } from '@tanstack/solid-query'\n *\n * const mutationKey = ['posts']\n *\n * function Posts() {\n * // Some mutation that we want to get the state for\n * const createPostsMutation = 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 *\n * return (\n * <button onClick={() => createPostsMutation.mutate(['New Post'])}>\n * Create post ({savedPosts().length} saved so far)\n * </button>\n * )\n * }\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 * ```tsx\n * import { useMutationState } from '@tanstack/solid-query'\n *\n * function LatestPost() {\n * const savedPosts = useMutationState(() => ({\n * filters: { mutationKey: ['posts'], status: 'success' },\n * select: (mutation) => mutation.state.data,\n * }))\n *\n * const latestPost = () => savedPosts()[savedPosts().length - 1]\n *\n * return <span>{latestPost()?.title}</span>\n * }\n * ```\n */\nexport function useMutationState<\n TResult = MutationState,\n TMutation extends Mutation<any, any, any, any> =\n MutationTypeFromResult<TResult>,\n>(\n options: Accessor<MutationStateOptions<TResult, TMutation>> = () => ({}),\n queryClient?: Accessor<QueryClient>,\n): Accessor<Array<TResult>> {\n const resolveClient = useQueryClientResolver(queryClient)\n const client = createMemo(() => resolveClient())\n const mutationCache = createMemo(() => client().getMutationCache())\n\n const [result, setResult] = createSignal(\n getResult(mutationCache(), options()),\n )\n\n createEffect(() => {\n const unsubscribe = mutationCache().subscribe(() => {\n const nextResult = replaceEqualDeep(\n result(),\n getResult(mutationCache(), options()),\n )\n if (result() !== nextResult) {\n setResult(nextResult)\n }\n })\n\n onCleanup(unsubscribe)\n })\n\n return result\n}\n","/* istanbul ignore file */\n\nimport { useQuery } from './useQuery'\nimport { useInfiniteQuery } from './useInfiniteQuery'\nimport { useMutation } from './useMutation'\nimport { useQueries } from './useQueries'\n\n// Re-export core\nexport * from '@tanstack/query-core'\n\n// Solid Query\nexport * from './types'\n\nexport type {\n DefinedUseBaseQueryResult,\n DefinedUseInfiniteQueryResult,\n DefinedUseQueryResult,\n InfiniteQueryOptions,\n MutationOptions,\n QueryOptions,\n UseBaseMutationResult,\n UseBaseQueryOptions,\n UseBaseQueryResult,\n UseInfiniteQueryOptions,\n UseInfiniteQueryResult,\n UseMutateAsyncFunction,\n UseMutateFunction,\n UseMutationOptions,\n UseMutationResult,\n UseQueryOptions,\n UseQueryResult,\n // Aliases (create* and use* are both supported)\n UseBaseQueryOptions as CreateBaseQueryOptions,\n UseBaseQueryResult as CreateBaseQueryResult,\n UseInfiniteQueryOptions as CreateInfiniteQueryOptions,\n UseInfiniteQueryResult as CreateInfiniteQueryResult,\n UseMutateAsyncFunction as CreateMutateAsyncFunction,\n UseMutateFunction as CreateMutateFunction,\n UseMutationOptions as CreateMutationOptions,\n UseMutationResult as CreateMutationResult,\n UseBaseMutationResult as CreateBaseMutationResult,\n UseQueryOptions as CreateQueryOptions,\n UseQueryResult as CreateQueryResult,\n DefinedUseBaseQueryResult as DefinedCreateBaseQueryResult,\n DefinedUseInfiniteQueryResult as DefinedCreateInfiniteQueryResult,\n DefinedUseQueryResult as DefinedCreateQueryResult,\n} from './types'\n\nexport { QueryClient } from './QueryClient'\nexport type {\n QueryObserverOptions,\n DefaultOptions,\n QueryClientConfig,\n InfiniteQueryObserverOptions,\n} from './QueryClient'\nexport { useQuery } from './useQuery'\nexport const createQuery = useQuery\nexport { queryOptions } from './queryOptions'\nexport type {\n DefinedInitialDataOptions,\n UndefinedInitialDataOptions,\n} from './queryOptions'\nexport {\n QueryClientContext,\n QueryClientProvider,\n useQueryClient,\n} from './QueryClientProvider'\nexport type { QueryClientProviderProps } from './QueryClientProvider'\nexport { useIsFetching } from './useIsFetching'\nexport { useIsFetching as createIsFetching } from './useIsFetching'\nexport { useInfiniteQuery }\nexport const createInfiniteQuery = useInfiniteQuery\nexport { infiniteQueryOptions } from './infiniteQueryOptions'\nexport type {\n DefinedInitialDataInfiniteOptions,\n UndefinedInitialDataInfiniteOptions,\n} from './infiniteQueryOptions'\nexport { useMutation } from './useMutation'\nexport { mutationOptions } from './mutationOptions'\nexport const createMutation = useMutation\nexport { useIsMutating } from './useIsMutating'\nexport { useIsMutating as createIsMutating } from './useIsMutating'\nexport { useMutationState } from './useMutationState'\nexport { useMutationState as createMutationState } from './useMutationState'\nexport { useQueries } from './useQueries'\nexport const createQueries = useQueries\nexport { useIsRestoring, IsRestoringProvider } from './isRestoring'\n"],"mappings":"qnBAYA,MAAaO,EAAqBP,EAEhCQ,IAAAA,EAAS,EAELC,EACJ,yDAUWC,EAAkBC,GAA8B,CAC3D,GAAIA,EACF,OAAOA,EAET,IAAMC,EAAST,EAAWI,CAAkB,EAE5C,GAAI,CAACK,EACH,MAAUC,MAAMJ,CAAuB,EAGzC,OAAOG,EAAO,CA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BD,EAAc,CAAC,EACzC0F,EAAgBzF,MAAiB5B,EAAO,CAAC,CAAC,iBAAiB,CAAC,EAE5D,CAACgB,EAAQ2G,GAAatF,EAC1BmF,EAAUH,EAAc,EAAGpF,EAAQ,CAAC,CACtC,EAgBA,OAdAgF,MAAmB,CACjB,IAAMhE,EAAcoE,EAAc,CAAC,CAAC,cAAgB,CAClD,IAAMO,EAAaC,EACjB7G,EAAO,EACPwG,EAAUH,EAAc,EAAGpF,EAAQ,CAAC,CACtC,EACIjB,EAAO,IAAM4G,GACfD,EAAUC,CAAU,CAExB,CAAC,EAEDnH,EAAUwC,CAAW,CACvB,CAAC,EAEMjC,CACT;;AClGA,MAAa8G,EAAcnD,EAedoD,EAAsBlD,EAQtBmD,EAAiBjD,EAMjBkD,GAAgB7C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/solid-query",
3
- "version": "5.103.2",
3
+ "version": "5.103.3",
4
4
  "description": "Primitives for managing, caching and syncing asynchronous and remote data in Solid",
5
5
  "author": "tannerlinsley",
6
6
  "license": "MIT",
@@ -46,15 +46,15 @@
46
46
  "!src/__tests__"
47
47
  ],
48
48
  "dependencies": {
49
- "@tanstack/query-core": "5.103.2"
49
+ "@tanstack/query-core": "5.103.3"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@solidjs/testing-library": "^0.8.10",
53
- "npm-run-all2": "^5.0.0",
54
- "solid-js": "^1.9.7",
53
+ "@tanstack/query-test-utils": "0.0.0",
54
+ "npm-run-all2": "^9.0.3",
55
+ "solid-js": "^1.9.15",
55
56
  "unplugin-solid": "^2.0.0",
56
- "vite-plugin-solid": "^2.11.6",
57
- "@tanstack/query-test-utils": "0.0.0"
57
+ "vite-plugin-solid": "^2.11.14"
58
58
  },
59
59
  "peerDependencies": {
60
60
  "solid-js": "^1.6.0"
@@ -45,9 +45,7 @@ export interface QueryObserverOptions<
45
45
  * Defaults reconciliation to false.
46
46
  */
47
47
  reconcile?:
48
- | string
49
- | false
50
- | ((oldData: TData | undefined, newData: TData) => TData)
48
+ string | false | ((oldData: TData | undefined, newData: TData) => TData)
51
49
  }
52
50
 
53
51
  /**
@@ -82,9 +80,7 @@ export interface InfiniteQueryObserverOptions<
82
80
  * Defaults reconciliation to false.
83
81
  */
84
82
  reconcile?:
85
- | string
86
- | false
87
- | ((oldData: TData | undefined, newData: TData) => TData)
83
+ string | false | ((oldData: TData | undefined, newData: TData) => TData)
88
84
  }
89
85
 
90
86
  /**
@@ -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.
@@ -30,7 +30,7 @@ export type UndefinedInitialDataOptions<
30
30
 
31
31
  /**
32
32
  * The options accepted by the `queryOptions` overload selected when `initialData` is set — `data` is never
33
- * `undefined`.
33
+ * `undefined` (unless a `select` changes `TData` to include `undefined`).
34
34
  *
35
35
  * @template TQueryFnData - The type your `queryFn` resolves to.
36
36
  * @template TError - The type of errors your `queryFn` may throw.
@@ -53,7 +53,8 @@ export type DefinedInitialDataOptions<
53
53
  * be shared across hooks and imperative APIs such as `queryClient.query`. `options.queryKey` is required and
54
54
  * is the query key to generate options for.
55
55
  *
56
- * This overload is selected when `initialData` is set, so the resulting `data` is never `undefined`.
56
+ * This overload is selected when `initialData` is set, so the resulting `data` is never `undefined` (unless
57
+ * a `select` changes `TData` to include `undefined`).
57
58
  *
58
59
  * @see {@link useQuery} to run a query with these options.
59
60
  * @param options - The {@link DefinedInitialDataOptions} to use — everything you can pass to `useQuery`, with `initialData` set.
package/src/types.ts CHANGED
@@ -124,7 +124,8 @@ export type UseQueryResult<
124
124
  > = UseBaseQueryResult<TData, TError>
125
125
 
126
126
  /**
127
- * The object `useQuery` returns when `initialData` guarantees `data` is never `undefined`.
127
+ * The object `useQuery` returns when `initialData` guarantees `data` is never `undefined` (unless a
128
+ * `select` changes `TData` to include `undefined`).
128
129
  *
129
130
  * @template TData - The type `data` ends up as, after `select` runs (if set).
130
131
  * @template TError - The type of errors this query may hold.
@@ -135,7 +136,8 @@ export type DefinedUseBaseQueryResult<
135
136
  > = DefinedQueryObserverResult<TData, TError>
136
137
 
137
138
  /**
138
- * The object `useQuery` returns when `initialData` guarantees `data` is never `undefined`.
139
+ * The object `useQuery` returns when `initialData` guarantees `data` is never `undefined` (unless a
140
+ * `select` changes `TData` to include `undefined`).
139
141
  *
140
142
  * @template TData - The type `data` ends up as, after `select` runs (if set).
141
143
  * @template TError - The type of errors this query may hold.
@@ -229,7 +231,8 @@ export type UseInfiniteQueryResult<
229
231
  > = InfiniteQueryObserverResult<TData, TError>
230
232
 
231
233
  /**
232
- * The object `useInfiniteQuery` returns when `initialData` guarantees `data` is never `undefined`.
234
+ * The object `useInfiniteQuery` returns when `initialData` guarantees `data` is never `undefined` (unless a
235
+ * `select` changes `TData` to include `undefined`).
233
236
  *
234
237
  * @template TData - The type `data` ends up as, after `select` runs (if set).
235
238
  * @template TError - The type of errors this query may hold.
@@ -28,9 +28,7 @@ function reconcileFn<TData, TError>(
28
28
  store: QueryObserverResult<TData, TError>,
29
29
  result: QueryObserverResult<TData, TError>,
30
30
  reconcileOption:
31
- | string
32
- | false
33
- | ((oldData: TData | undefined, newData: TData) => TData),
31
+ string | false | ((oldData: TData | undefined, newData: TData) => TData),
34
32
  queryHash?: string,
35
33
  ): QueryObserverResult<TData, TError> {
36
34
  if (reconcileOption === false) return result
@@ -342,7 +340,7 @@ export function useBaseQuery<
342
340
  )
343
341
 
344
342
  onCleanup(() => {
345
- if (isServer && queryResource.loading) {
343
+ if (isServer && queryResource.state === 'pending') {
346
344
  unsubscribeQueued = true
347
345
  return
348
346
  }
package/src/useQuery.ts CHANGED
@@ -127,7 +127,9 @@ import type {
127
127
  * ```
128
128
  *
129
129
  * @example
130
- * Seeding a detail query from an already-cached list, to skip the loading state:
130
+ * Seeding a detail query from an already-cached list, to skip the loading state. `initialDataUpdatedAt` carries
131
+ * over the list's own fetch time, so that if you set a `staleTime`, it's measured from when the list was
132
+ * fetched rather than from now:
131
133
  * ```tsx
132
134
  * import { useQuery, useQueryClient } from '@tanstack/solid-query'
133
135
  *
@@ -141,6 +143,8 @@ import type {
141
143
  * queryClient
142
144
  * .getQueryData<Array<Post>>(['posts'])
143
145
  * ?.find((post) => post.id === props.postId),
146
+ * initialDataUpdatedAt: () =>
147
+ * queryClient.getQueryState(['posts'])?.dataUpdatedAt,
144
148
  * }))
145
149
  *
146
150
  * return postQuery.isError ? <span>Error: {postQuery.error.message}</span> : <h1>{postQuery.data?.title}</h1>
@@ -192,7 +196,8 @@ export function useQuery<
192
196
  * Subscribes to a query: a declarative dependency on an asynchronous source of data that is tied to a unique key.
193
197
  * The query runs when the options call for it — `enabled: false` skips the initial fetch.
194
198
  *
195
- * This overload is selected when `initialData` is set, so the resulting `data` is never `undefined`.
199
+ * This overload is selected when `initialData` is set, so the resulting `data` is never `undefined` (unless
200
+ * a `select` changes `TData` to include `undefined`).
196
201
  *
197
202
  * @see {@link queryOptions} to share these options between `useQuery` and imperative APIs like `queryClient.query`.
198
203
  * @param options - An accessor returning the {@link DefinedInitialDataOptions} to use — everything you can