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

Method fetchFn

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

Source from the content-addressed store, hash-verified

770
771 // Create fetch function
772 const fetchFn = () => {
773 const queryFn = ensureQueryFn(this.options, fetchOptions)
774
775 // Create query function context
776 const createQueryFnContext = (): QueryFunctionContext<TQueryKey> => {
777 const queryFnContext: OmitKeyof<
778 QueryFunctionContext<TQueryKey>,
779 'signal'
780 > = {
781 client: this.#client,
782 queryKey: this.queryKey,
783 meta: this.meta,
784 }
785 addSignalProperty(queryFnContext)
786 return queryFnContext as QueryFunctionContext<TQueryKey>
787 }
788
789 const queryFnContext = createQueryFnContext()
790
791 this.#abortSignalConsumed = false
792 if (this.options.persister) {
793 return this.options.persister(
794 queryFn,
795 queryFnContext,
796 this as unknown as Query,
797 )
798 }
799
800 return queryFn(queryFnContext)
801 }
802
803 // Trigger behavior hook
804 const createFetchContext = (): FetchContext<

Callers 1

Calls 3

ensureQueryFnFunction · 0.90
createQueryFnContextFunction · 0.85
queryFnFunction · 0.50

Tested by

no test coverage detected