MCPcopy Create free account
hub / github.com/TanStack/query / hashKey

Function hashKey

packages/query-core/src/utils.ts:223–234  ·  view source on GitHub ↗
(queryKey: QueryKey | MutationKey)

Source from the content-addressed store, hash-verified

221 * Hashes the value into a stable hash.
222 */
223export function hashKey(queryKey: QueryKey | MutationKey): string {
224 return JSON.stringify(queryKey, (_, val) =>
225 isPlainObject(val)
226 ? Object.keys(val)
227 .sort()
228 .reduce((result, key) => {
229 result[key] = val[key]
230 return result
231 }, {} as any)
232 : val,
233 )
234}
235
236/**
237 * Checks if key `b` partially matches with key `a`.

Callers 11

restoreQueriesFunction · 0.90
removeQueriesFunction · 0.90
setupPersisterFunction · 0.90
setQueryDefaultsMethod · 0.90
setMutationDefaultsMethod · 0.90
setOptionsMethod · 0.90
utils.test.tsxFile · 0.90
matchMutationFunction · 0.85

Calls 1

isPlainObjectFunction · 0.70

Tested by 1

setupPersisterFunction · 0.72