(
store: QueryObserverResult<TData, TError>,
result: QueryObserverResult<TData, TError>,
reconcileOption:
| string
| false
| ((oldData: TData | undefined, newData: TData) => TData),
queryHash?: string,
)
| 25 | } from '@tanstack/query-core' |
| 26 | |
| 27 | function reconcileFn<TData, TError>( |
| 28 | store: QueryObserverResult<TData, TError>, |
| 29 | result: QueryObserverResult<TData, TError>, |
| 30 | reconcileOption: |
| 31 | | string |
| 32 | | false |
| 33 | | ((oldData: TData | undefined, newData: TData) => TData), |
| 34 | queryHash?: string, |
| 35 | ): QueryObserverResult<TData, TError> { |
| 36 | if (reconcileOption === false) return result |
| 37 | if (typeof reconcileOption === 'function') { |
| 38 | const newData = reconcileOption(store.data, result.data as TData) |
| 39 | return { ...result, data: newData } as typeof result |
| 40 | } |
| 41 | let data = result.data |
| 42 | if (store.data === undefined) { |
| 43 | try { |
| 44 | data = structuredClone(data) |
| 45 | } catch (error) { |
| 46 | if (process.env.NODE_ENV !== 'production') { |
| 47 | if (error instanceof Error) { |
| 48 | console.warn( |
| 49 | `Unable to correctly reconcile data for query key: ${queryHash}. ` + |
| 50 | `Possibly because the query data contains data structures that aren't supported ` + |
| 51 | `by the 'structuredClone' algorithm. Consider using a callback function instead ` + |
| 52 | `to manage the reconciliation manually.\n\n Error Received: ${error.name} - ${error.message}`, |
| 53 | ) |
| 54 | } |
| 55 | } |
| 56 | } |
| 57 | } |
| 58 | const newData = reconcile(data, { key: reconcileOption })(store.data) |
| 59 | return { ...result, data: newData } as typeof result |
| 60 | } |
| 61 | |
| 62 | /** |
| 63 | * Solid's `onHydrated` functionality will silently "fail" (hydrate with an empty object) |
no test coverage detected
searching dependent graphs…