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

Function hashKey

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

Source from the content-addressed store, hash-verified

230 * Hashes the value into a stable hash.
231 */
232export function hashKey(queryKey: QueryKey | MutationKey): string {
233 return JSON.stringify(queryKey, (_, val) =>
234 isPlainObject(val)
235 ? Object.keys(val)
236 .sort()
237 .reduce((result, key) => {
238 result[key] = val[key]
239 return result
240 }, {} as any)
241 : val,
242 )
243}
244
245/**
246 * 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