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

Function matchMutation

packages/query-core/src/utils.ts:237–264  ·  view source on GitHub ↗
(
  filters: MutationFilters,
  mutation: Mutation<any, any>,
)

Source from the content-addressed store, hash-verified

235 * ```
236 */
237export function matchMutation(
238 filters: MutationFilters,
239 mutation: Mutation<any, any>,
240): boolean {
241 const { exact, status, predicate, mutationKey } = filters
242 if (mutationKey) {
243 if (!mutation.options.mutationKey) {
244 return false
245 }
246 if (exact) {
247 if (hashKey(mutation.options.mutationKey) !== hashKey(mutationKey)) {
248 return false
249 }
250 } else if (!partialMatchKey(mutation.options.mutationKey, mutationKey)) {
251 return false
252 }
253 }
254
255 if (status && mutation.state.status !== status) {
256 return false
257 }
258
259 if (predicate && !predicate(mutation)) {
260 return false
261 }
262
263 return true
264}
265
266export function hashQueryKeyByOptions<TQueryKey extends QueryKey = QueryKey>(
267 queryKey: TQueryKey,

Callers 4

findMethod · 0.90
findAllMethod · 0.90
utils.test-d.tsxFile · 0.90
utils.test.tsxFile · 0.90

Calls 3

hashKeyFunction · 0.85
partialMatchKeyFunction · 0.85
predicateFunction · 0.50

Tested by

no test coverage detected