MCPcopy Index your code
hub / github.com/TanStack/query / hydratableObserverResult

Function hydratableObserverResult

packages/solid-query/src/useBaseQuery.ts:66–100  ·  view source on GitHub ↗
(
  query: Query<TQueryFnData, TError, TData, TQueryKey>,
  result: QueryObserverResult<TDataHydratable, TError>,
)

Source from the content-addressed store, hash-verified

64 * if the resource data is not serializable.
65 */
66const hydratableObserverResult = <
67 TQueryFnData,
68 TError,
69 TData,
70 TQueryKey extends QueryKey,
71 TDataHydratable,
72>(
73 query: Query<TQueryFnData, TError, TData, TQueryKey>,
74 result: QueryObserverResult<TDataHydratable, TError>,
75) => {
76 if (!isServer) return result
77 const obj: any = {
78 ...unwrap(result),
79 // During SSR, functions cannot be serialized, so we need to remove them
80 // This is safe because we will add these functions back when the query is hydrated
81 refetch: undefined,
82 }
83
84 // If the query is an infinite query, we need to remove additional properties
85 if ('fetchNextPage' in result) {
86 obj.fetchNextPage = undefined
87 obj.fetchPreviousPage = undefined
88 }
89
90 // We will also attach the dehydrated state of the query to the result
91 // This will be removed on client after hydration
92 obj.hydrationData = {
93 state: query.state,
94 queryKey: query.queryKey,
95 queryHash: query.queryHash,
96 ...(query.meta && { meta: query.meta }),
97 }
98
99 return obj
100}
101
102// Base Query Function that is used to create the query.
103export function useBaseQuery<

Callers 2

createServerSubscriberFunction · 0.85
useBaseQueryFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…