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

Function matchMutation

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

Source from the content-addressed store, hash-verified

189}
190
191export function matchMutation(
192 filters: MutationFilters,
193 mutation: Mutation<any, any>,
194): boolean {
195 const { exact, status, predicate, mutationKey } = filters
196 if (mutationKey) {
197 if (!mutation.options.mutationKey) {
198 return false
199 }
200 if (exact) {
201 if (hashKey(mutation.options.mutationKey) !== hashKey(mutationKey)) {
202 return false
203 }
204 } else if (!partialMatchKey(mutation.options.mutationKey, mutationKey)) {
205 return false
206 }
207 }
208
209 if (status && mutation.state.status !== status) {
210 return false
211 }
212
213 if (predicate && !predicate(mutation)) {
214 return false
215 }
216
217 return true
218}
219
220export function hashQueryKeyByOptions<TQueryKey extends QueryKey = QueryKey>(
221 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