diff --git a/src/core/infiniteQueryObserver.ts b/src/core/infiniteQueryObserver.ts index 063b01ae89..1622ed0777 100644 --- a/src/core/infiniteQueryObserver.ts +++ b/src/core/infiniteQueryObserver.ts @@ -1,4 +1,5 @@ import type { + DefaultedInfiniteQueryObserverOptions, FetchNextPageOptions, FetchPreviousPageOptions, InfiniteData, @@ -84,7 +85,7 @@ export class InfiniteQueryObserver< } getOptimisticResult( - options: InfiniteQueryObserverOptions< + options: DefaultedInfiniteQueryObserverOptions< TQueryFnData, TError, TData, diff --git a/src/core/queryObserver.ts b/src/core/queryObserver.ts index f228606671..95b0d080bf 100644 --- a/src/core/queryObserver.ts +++ b/src/core/queryObserver.ts @@ -1,4 +1,4 @@ -import { RefetchPageFilters } from './types' +import { DefaultedQueryObserverOptions, RefetchPageFilters } from './types' import { isServer, isValidTimeout, @@ -205,7 +205,7 @@ export class QueryObserver< } getOptimisticResult( - options: QueryObserverOptions< + options: DefaultedQueryObserverOptions< TQueryFnData, TError, TData, @@ -213,13 +213,9 @@ export class QueryObserver< TQueryKey > ): QueryObserverResult { - const defaultedOptions = this.client.defaultQueryOptions(options) - - const query = this.client - .getQueryCache() - .build(this.client, defaultedOptions) + const query = this.client.getQueryCache().build(this.client, options) - return this.createResult(query, defaultedOptions) + return this.createResult(query, options) } getCurrentResult(): QueryObserverResult { diff --git a/src/core/types.ts b/src/core/types.ts index 0dab1232ca..8ec2927b9b 100644 --- a/src/core/types.ts +++ b/src/core/types.ts @@ -246,6 +246,23 @@ export interface InfiniteQueryObserverOptions< TQueryKey > {} +export type DefaultedInfiniteQueryObserverOptions< + TQueryFnData = unknown, + TError = unknown, + TData = TQueryFnData, + TQueryData = TQueryFnData, + TQueryKey extends QueryKey = QueryKey +> = WithRequired< + InfiniteQueryObserverOptions< + TQueryFnData, + TError, + TData, + TQueryData, + TQueryKey + >, + 'useErrorBoundary' | 'refetchOnReconnect' +> + export interface FetchQueryOptions< TQueryFnData = unknown, TError = unknown,