Skip to content
Source
Sign inSign up
TanStack/query
Open History to see the last commit

QueryOptions.md

213 lines5.1 KB

Interface: QueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>

Defined in: packages/query-core/src/types.ts:225

Type Parameters

TQueryFnData

TQueryFnData = unknown

TError

TError = DefaultError

TData

TData = TQueryFnData

TQueryKey

TQueryKey extends QueryKey = QueryKey

TPageParam

TPageParam = never

Properties

_defaulted?

optional _defaulted: boolean;

Defined in: packages/query-core/src/types.ts:268


behavior?

optional behavior: QueryBehavior<TQueryFnData, TError, TData, TQueryKey>;

Defined in: packages/query-core/src/types.ts:259


gcTime?

optional gcTime: number;

Defined in: packages/query-core/src/types.ts:247

The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to Infinity will disable garbage collection.


initialData?

optional initialData: 
  | TData
| InitialDataFunction<TData>;

Defined in: packages/query-core/src/types.ts:257


initialDataUpdatedAt?

optional initialDataUpdatedAt: number | () => number | undefined;

Defined in: packages/query-core/src/types.ts:258


maxPages?

optional maxPages: number;

Defined in: packages/query-core/src/types.ts:277

Maximum number of pages to store in the data of an infinite query.


meta?

optional meta: Record<string, unknown>;

Defined in: packages/query-core/src/types.ts:273

Additional payload to be stored on each query. Use this property to pass information that can be used in other places.


networkMode?

optional networkMode: NetworkMode;

Defined in: packages/query-core/src/types.ts:240


persister?

optional persister: QueryPersister<NoInfer<TQueryFnData>, NoInfer<TQueryKey>, NoInfer<TPageParam>>;

Defined in: packages/query-core/src/types.ts:249


queryFn?

optional queryFn: 
  | QueryFunction<TQueryFnData, TQueryKey, TPageParam>
  | typeof skipToken;

Defined in: packages/query-core/src/types.ts:248


queryHash?

optional queryHash: string;

Defined in: packages/query-core/src/types.ts:254


queryKey?

optional queryKey: TQueryKey;

Defined in: packages/query-core/src/types.ts:255


queryKeyHashFn?

optional queryKeyHashFn: QueryKeyHashFunction<TQueryKey>;

Defined in: packages/query-core/src/types.ts:256


retry?

optional retry: RetryValue<TError>;

Defined in: packages/query-core/src/types.ts:238

If false, failed queries will not retry by default. If true, failed queries will retry infinitely., failureCount: num If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function (failureCount, error) => boolean failed queries will retry until the function returns false.


retryDelay?

optional retryDelay: RetryDelayValue<TError>;

Defined in: packages/query-core/src/types.ts:239


structuralSharing?

optional structuralSharing: boolean | (oldData, newData) => unknown;

Defined in: packages/query-core/src/types.ts:265

Set this to false to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. Defaults to true.