MCPcopy
hub / github.com/TanStack/query / matchMutation

Function matchMutation

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

Source from the content-addressed store, hash-verified

173}
174
175export function matchMutation(
176 filters: MutationFilters,
177 mutation: Mutation<any, any>,
178): boolean {
179 const { exact, status, predicate, mutationKey } = filters
180 if (mutationKey) {
181 if (!mutation.options.mutationKey) {
182 return false
183 }
184 if (exact) {
185 if (hashKey(mutation.options.mutationKey) !== hashKey(mutationKey)) {
186 return false
187 }
188 } else if (!partialMatchKey(mutation.options.mutationKey, mutationKey)) {
189 return false
190 }
191 }
192
193 if (status && mutation.state.status !== status) {
194 return false
195 }
196
197 if (predicate && !predicate(mutation)) {
198 return false
199 }
200
201 return true
202}
203
204export function hashQueryKeyByOptions<TQueryKey extends QueryKey = QueryKey>(
205 queryKey: TQueryKey,

Callers 3

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

Calls 3

hashKeyFunction · 0.85
partialMatchKeyFunction · 0.85
predicateFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…