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

Method fetchFn

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

Source from the content-addressed store, hash-verified

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

Callers 1

Calls 3

ensureQueryFnFunction · 0.90
createQueryFnContextFunction · 0.85
queryFnFunction · 0.50

Tested by

no test coverage detected