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

Method fetchFn

packages/query-core/src/query.ts:460–489  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

458
459 // Create fetch function
460 const fetchFn = () => {
461 const queryFn = ensureQueryFn(this.options, fetchOptions)
462
463 // Create query function context
464 const createQueryFnContext = (): QueryFunctionContext<TQueryKey> => {
465 const queryFnContext: OmitKeyof<
466 QueryFunctionContext<TQueryKey>,
467 'signal'
468 > = {
469 client: this.#client,
470 queryKey: this.queryKey,
471 meta: this.meta,
472 }
473 addSignalProperty(queryFnContext)
474 return queryFnContext as QueryFunctionContext<TQueryKey>
475 }
476
477 const queryFnContext = createQueryFnContext()
478
479 this.#abortSignalConsumed = false
480 if (this.options.persister) {
481 return this.options.persister(
482 queryFn,
483 queryFnContext,
484 this as unknown as Query,
485 )
486 }
487
488 return queryFn(queryFnContext)
489 }
490
491 // Trigger behavior hook
492 const createFetchContext = (): FetchContext<

Callers 1

Calls 3

ensureQueryFnFunction · 0.90
createQueryFnContextFunction · 0.85
queryFnFunction · 0.50

Tested by

no test coverage detected