MCPcopy
hub / github.com/TanStack/query / fetchOptimistic

Method fetchOptimistic

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

Source from the content-addressed store, hash-verified

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

Callers 3

runFunction · 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