(key: QueryKey)
| 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 |
no test coverage detected