What is a query key?
Every cache entry is identified by a query key — a deterministic string derived from the endpoint method, path, and parameters:Stable serialization
Parameters are JSON-serialized with alphabetically sorted keys, ensuring that{ b: 2, a: 1 } and { a: 1, b: 2 } produce the same cache key:
undefinedvalues are dropped from objectsDateobjects are serialized to ISO stringsNaNandInfinityare preserved as"NaN"/"Infinity"nullis preserved- Arrays preserve order
- Functions and symbols throw in development
Hashing for large keys
When a serialized key exceeds 1024 characters, kweri hashes it withcrypto.subtle.digest('SHA-256') and stores the hash instead. The original key is kept alongside for display in DevTools.
This keeps memory usage bounded when params contain large objects (e.g., full filter sets).
Reading a key
Key-based invalidation
TheinvalidateByKey and removeByKey methods accept the serialized key string directly — primarily used by DevTools:
invalidateByPath or invalidateQuery since they don’t require you to construct the key string.
How params are flattened
When you callkweri.query(endpoint, params), params in the nested { path, query, body } shape are flattened before being passed to the ApiClient:
path.*keys merge to the top level (used for{id}substitution)query.*keys merge to the top level (appended as query string)bodystays asbody(JSON-encoded as the request body)