( query: Query<TQueryFnData, TError, TData, TQueryKey>, result: QueryObserverResult<TDataHydratable, TError>, )
| 64 | * if the resource data is not serializable. |
| 65 | */ |
| 66 | const 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. |
| 103 | export function useBaseQuery< |
no outgoing calls
no test coverage detected
searching dependent graphs…