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

Function matchMutation

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

Source from the content-addressed store, hash-verified

180}
181
182export function matchMutation(
183 filters: MutationFilters,
184 mutation: Mutation<any, any>,
185): boolean {
186 const { exact, status, predicate, mutationKey } = filters
187 if (mutationKey) {
188 if (!mutation.options.mutationKey) {
189 return false
190 }
191 if (exact) {
192 if (hashKey(mutation.options.mutationKey) !== hashKey(mutationKey)) {
193 return false
194 }
195 } else if (!partialMatchKey(mutation.options.mutationKey, mutationKey)) {
196 return false
197 }
198 }
199
200 if (status && mutation.state.status !== status) {
201 return false
202 }
203
204 if (predicate && !predicate(mutation)) {
205 return false
206 }
207
208 return true
209}
210
211export function hashQueryKeyByOptions<TQueryKey extends QueryKey = QueryKey>(
212 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