From 2eb06bca3b48c4d9553bf433dbd5f9a9c4e1ae05 Mon Sep 17 00:00:00 2001 From: Robert Kuzhin Date: Fri, 9 Aug 2024 14:37:07 +0300 Subject: [PATCH] feat: export partialMatchKey util --- docs/framework/react/guides/filters.md | 13 +++++++++++++ packages/query-core/src/index.ts | 1 + 2 files changed, 14 insertions(+) diff --git a/docs/framework/react/guides/filters.md b/docs/framework/react/guides/filters.md index a4e20cde674..b77d4a4d024 100644 --- a/docs/framework/react/guides/filters.md +++ b/docs/framework/react/guides/filters.md @@ -88,3 +88,16 @@ const isMatching = matchMutation(filters, mutation) ``` Returns a boolean that indicates whether a mutation matches the provided set of mutation filters. + +### `partialMatchKey` + +```tsx +const isPartialMatch = partialMatchKey(keyA, keyB) +``` + +Determines whether the query key `keyB` partially matches the query key `keyA` and returns a boolean. + +Use Cases: + +- Filtering queries based on partial match of query keys. +- Checking if a query key is a subset of another query key, to perform the required logic. diff --git a/packages/query-core/src/index.ts b/packages/query-core/src/index.ts index 684256b572f..c1dc7578ed5 100644 --- a/packages/query-core/src/index.ts +++ b/packages/query-core/src/index.ts @@ -18,6 +18,7 @@ export { replaceEqualDeep, isServer, matchQuery, + partialMatchKey, matchMutation, keepPreviousData, skipToken,