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

Method fetchOptimistic

packages/query-core/src/queryObserver.ts:305–321  ·  view source on GitHub ↗
(
    options: QueryObserverOptions<
      TQueryFnData,
      TError,
      TData,
      TQueryData,
      TQueryKey
    >,
  )

Source from the content-addressed store, hash-verified

303 }
304
305 fetchOptimistic(
306 options: QueryObserverOptions<
307 TQueryFnData,
308 TError,
309 TData,
310 TQueryData,
311 TQueryKey
312 >,
313 ): Promise<QueryObserverResult<TData, TError>> {
314 const defaultedOptions = this.#client.defaultQueryOptions(options)
315
316 const query = this.#client
317 .getQueryCache()
318 .build(this.#client, defaultedOptions)
319
320 return query.fetch().then(() => this.createResult(query, defaultedOptions))
321 }
322
323 protected fetch(
324 fetchOptions: ObserverFetchOptions,

Callers 5

QueryControllerClass · 0.80
runFunction · 0.80
fetchOptimisticFunction · 0.80
fetchOptimisticFunction · 0.80

Calls 5

createResultMethod · 0.95
defaultQueryOptionsMethod · 0.80
getQueryCacheMethod · 0.80
buildMethod · 0.45
fetchMethod · 0.45

Tested by

no test coverage detected