@tanstack/solid-query
Advanced tools
Comparing version 5.30.1 to 5.30.2
@@ -53,3 +53,3 @@ import { QueryClient as QueryClient$1, MutationObserver, replaceEqualDeep, QueriesObserver, hydrate, QueryObserver, InfiniteQueryObserver, notifyManager } from '@tanstack/query-core'; | ||
// src/createBaseQuery.ts | ||
function reconcileFn(store, result, reconcileOption) { | ||
function reconcileFn(store, result, reconcileOption, queryHash) { | ||
if (reconcileOption === false) | ||
@@ -61,3 +61,19 @@ return result; | ||
} | ||
const newData = reconcile(result.data, { key: reconcileOption })(store.data); | ||
let data = result.data; | ||
if (store.data === void 0) { | ||
try { | ||
data = structuredClone(data); | ||
} catch (error) { | ||
{ | ||
if (error instanceof Error) { | ||
console.warn( | ||
`Unable to correctly reconcile data for query key: ${queryHash}. Possibly because the query data contains data structures that aren't supported by the 'structuredClone' algorithm. Consider using a callback function instead to manage the reconciliation manually. | ||
Error Received: ${error.name} - ${error.message}` | ||
); | ||
} | ||
} | ||
} | ||
} | ||
const newData = reconcile(data, { key: reconcileOption })(store.data); | ||
return { ...result, data: newData }; | ||
@@ -137,3 +153,4 @@ } | ||
function setStateWithReconciliation(res) { | ||
const reconcileOptions = observer().options.reconcile; | ||
const opts = observer().options; | ||
const reconcileOptions = opts.reconcile; | ||
setState((store) => { | ||
@@ -143,3 +160,4 @@ return reconcileFn( | ||
res, | ||
reconcileOptions === void 0 ? false : reconcileOptions | ||
reconcileOptions === void 0 ? false : reconcileOptions, | ||
opts.queryHash | ||
); | ||
@@ -217,3 +235,3 @@ }); | ||
observer().setOptions(newOptions); | ||
setState(observer().getOptimisticResult(newOptions)); | ||
setStateWithReconciliation(observer().getOptimisticResult(newOptions)); | ||
unsubscribe = createClientSubscriber(); | ||
@@ -273,4 +291,3 @@ } | ||
if (prop === "data") { | ||
const opts = observer().options; | ||
if (opts.placeholderData) { | ||
if (state.data !== void 0) { | ||
return queryResource.latest?.data; | ||
@@ -277,0 +294,0 @@ } |
@@ -53,3 +53,3 @@ import { QueryClient as QueryClient$1, MutationObserver, replaceEqualDeep, QueriesObserver, hydrate, QueryObserver, InfiniteQueryObserver, notifyManager } from '@tanstack/query-core'; | ||
// src/createBaseQuery.ts | ||
function reconcileFn(store, result, reconcileOption) { | ||
function reconcileFn(store, result, reconcileOption, queryHash) { | ||
if (reconcileOption === false) | ||
@@ -61,3 +61,10 @@ return result; | ||
} | ||
const newData = reconcile(result.data, { key: reconcileOption })(store.data); | ||
let data = result.data; | ||
if (store.data === void 0) { | ||
try { | ||
data = structuredClone(data); | ||
} catch (error) { | ||
} | ||
} | ||
const newData = reconcile(data, { key: reconcileOption })(store.data); | ||
return { ...result, data: newData }; | ||
@@ -137,3 +144,4 @@ } | ||
function setStateWithReconciliation(res) { | ||
const reconcileOptions = observer().options.reconcile; | ||
const opts = observer().options; | ||
const reconcileOptions = opts.reconcile; | ||
setState((store) => { | ||
@@ -143,3 +151,4 @@ return reconcileFn( | ||
res, | ||
reconcileOptions === void 0 ? false : reconcileOptions | ||
reconcileOptions === void 0 ? false : reconcileOptions, | ||
opts.queryHash | ||
); | ||
@@ -217,3 +226,3 @@ }); | ||
observer().setOptions(newOptions); | ||
setState(observer().getOptimisticResult(newOptions)); | ||
setStateWithReconciliation(observer().getOptimisticResult(newOptions)); | ||
unsubscribe = createClientSubscriber(); | ||
@@ -273,4 +282,3 @@ } | ||
if (prop === "data") { | ||
const opts = observer().options; | ||
if (opts.placeholderData) { | ||
if (state.data !== void 0) { | ||
return queryResource.latest?.data; | ||
@@ -277,0 +285,0 @@ } |
{ | ||
"name": "@tanstack/solid-query", | ||
"version": "5.30.1", | ||
"version": "5.30.2", | ||
"description": "Primitives for managing, caching and syncing asynchronous and remote data in Solid", | ||
@@ -5,0 +5,0 @@ "author": "tannerlinsley", |
@@ -37,2 +37,3 @@ // Had to disable the lint rule because isServer type is defined as false | ||
| ((oldData: TData | undefined, newData: TData) => TData), | ||
queryHash?: string, | ||
): QueryObserverResult<TData, TError> { | ||
@@ -44,3 +45,20 @@ if (reconcileOption === false) return result | ||
} | ||
const newData = reconcile(result.data, { key: reconcileOption })(store.data) | ||
let data = result.data | ||
if (store.data === undefined) { | ||
try { | ||
data = structuredClone(data) | ||
} catch (error) { | ||
if (process.env.NODE_ENV !== 'production') { | ||
if (error instanceof Error) { | ||
console.warn( | ||
`Unable to correctly reconcile data for query key: ${queryHash}. ` + | ||
`Possibly because the query data contains data structures that aren't supported ` + | ||
`by the 'structuredClone' algorithm. Consider using a callback function instead ` + | ||
`to manage the reconciliation manually.\n\n Error Received: ${error.name} - ${error.message}`, | ||
) | ||
} | ||
} | ||
} | ||
} | ||
const newData = reconcile(data, { key: reconcileOption })(store.data) | ||
return { ...result, data: newData } as typeof result | ||
@@ -191,4 +209,5 @@ } | ||
function setStateWithReconciliation(res: typeof observerResult) { | ||
const opts = observer().options | ||
// @ts-expect-error - Reconcile option is not correctly typed internally | ||
const reconcileOptions = observer().options.reconcile | ||
const reconcileOptions = opts.reconcile | ||
@@ -200,2 +219,3 @@ setState((store) => { | ||
reconcileOptions === undefined ? false : reconcileOptions, | ||
opts.queryHash, | ||
) | ||
@@ -297,3 +317,3 @@ }) | ||
observer().setOptions(newOptions) | ||
setState(observer().getOptimisticResult(newOptions)) | ||
setStateWithReconciliation(observer().getOptimisticResult(newOptions)) | ||
unsubscribe = createClientSubscriber() | ||
@@ -361,4 +381,3 @@ }, | ||
if (prop === 'data') { | ||
const opts = observer().options | ||
if (opts.placeholderData) { | ||
if (state.data !== undefined) { | ||
return queryResource.latest?.data | ||
@@ -365,0 +384,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
443349
13387