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

Method canRun

packages/query-core/src/mutationCache.ts:195–210  ·  view source on GitHub ↗

@internal

(mutation: Mutation<any, any, any, any>)

Source from the content-addressed store, hash-verified

193
194 /** @internal */
195 canRun(mutation: Mutation<any, any, any, any>): boolean {
196 const scope = scopeFor(mutation)
197 if (typeof scope === 'string') {
198 const mutationsWithSameScope = this.#scopes.get(scope)
199 const firstPendingMutation = mutationsWithSameScope?.find(
200 (m) => m.state.status === 'pending',
201 )
202 // we can run if there is no current pending mutation (start use-case)
203 // or if WE are the first pending mutation (continue use-case)
204 return !firstPendingMutation || firstPendingMutation === mutation
205 } else {
206 // For unscoped mutations there are never any pending mutations in front of the
207 // current mutation
208 return true
209 }
210 }
211
212 /** @internal */
213 runNext(mutation: Mutation<any, any, any, any>): Promise<unknown> {

Callers 3

executeMethod · 0.80
canContinueFunction · 0.80
canStartFunction · 0.80

Calls 3

scopeForFunction · 0.85
getMethod · 0.80
findMethod · 0.45

Tested by

no test coverage detected