(
client: QueryClient,
options: DehydrateOptions = {},
)
| 120 | } |
| 121 | |
| 122 | export function dehydrate( |
| 123 | client: QueryClient, |
| 124 | options: DehydrateOptions = {}, |
| 125 | ): DehydratedState { |
| 126 | const filterMutation = |
| 127 | options.shouldDehydrateMutation ?? |
| 128 | client.getDefaultOptions().dehydrate?.shouldDehydrateMutation ?? |
| 129 | defaultShouldDehydrateMutation |
| 130 | |
| 131 | const mutations = client |
| 132 | .getMutationCache() |
| 133 | .getAll() |
| 134 | .flatMap((mutation) => |
| 135 | filterMutation(mutation) ? [dehydrateMutation(mutation)] : [], |
| 136 | ) |
| 137 | |
| 138 | const filterQuery = |
| 139 | options.shouldDehydrateQuery ?? |
| 140 | client.getDefaultOptions().dehydrate?.shouldDehydrateQuery ?? |
| 141 | defaultShouldDehydrateQuery |
| 142 | |
| 143 | const shouldRedactErrors = |
| 144 | options.shouldRedactErrors ?? |
| 145 | client.getDefaultOptions().dehydrate?.shouldRedactErrors ?? |
| 146 | defaultShouldRedactErrors |
| 147 | |
| 148 | const serializeData = |
| 149 | options.serializeData ?? |
| 150 | client.getDefaultOptions().dehydrate?.serializeData ?? |
| 151 | defaultTransformerFn |
| 152 | |
| 153 | const queries = client |
| 154 | .getQueryCache() |
| 155 | .getAll() |
| 156 | .flatMap((query) => |
| 157 | filterQuery(query) |
| 158 | ? [dehydrateQuery(query, serializeData, shouldRedactErrors)] |
| 159 | : [], |
| 160 | ) |
| 161 | |
| 162 | return { mutations, queries } |
| 163 | } |
| 164 | |
| 165 | export function hydrate( |
| 166 | client: QueryClient, |
no test coverage detected
searching dependent graphs…