MCPcopy Index your code
hub / github.com/TanStack/db / validateQueryKeyPrefix

Function validateQueryKeyPrefix

packages/query-db-collection/src/query.ts:614–626  ·  view source on GitHub ↗
(key: QueryKey)

Source from the content-addressed store, hash-verified

612 * must start with baseKey for stale cache updates to work correctly.
613 */
614 const validateQueryKeyPrefix = (key: QueryKey): void => {
615 if (typeof queryKey !== `function`) return
616 const isValidPrefix =
617 key.length >= baseKey.length &&
618 baseKey.every((segment, i) => deepEquals(segment, key[i]))
619 if (!isValidPrefix) {
620 console.warn(
621 `[QueryCollection] queryKey function must return keys that extend the base key prefix. ` +
622 `Base: ${JSON.stringify(baseKey)}, Got: ${JSON.stringify(key)}. ` +
623 `This can cause stale cache issues.`,
624 )
625 }
626 }
627
628 // Validate required parameters
629

Callers 1

createQueryFromOptsFunction · 0.85

Calls 1

deepEqualsFunction · 0.90

Tested by

no test coverage detected