Skip to content

API reference > @kontsedal/olas-core > InfiniteQuerySpec

InfiniteQuerySpec type ​

Configuration for defineInfiniteQuery({ ... }). Spec §5.11, §20.4.

  • getNextPageParam(lastPage, allPages) returns the param for the next page, or null when there's no more. - getPreviousPageParam (optional) enables bidirectional infinite lists. - itemsOf(page) (optional) flattens pages into items for the subscription.flat convenience signal.

Signature:

typescript
type InfiniteQuerySpec<Args extends unknown[], PageParam, TPage, TItem = TPage> = {
  id: string;
  key: (...args: Args) => unknown[];
  fetcher: (ctx: InfiniteFetchCtx<PageParam>, ...args: Args) => Promise<TPage>;
  initialPageParam: PageParam;
  getNextPageParam: (lastPage: TPage, allPages: TPage[]) => PageParam | null;
  getPreviousPageParam?: (firstPage: TPage, allPages: TPage[]) => PageParam | null;
  itemsOf?: (page: TPage) => TItem[];
  staleTime?: number;
  gcTime?: number;
  refetchInterval?: RefetchInterval<TPage[]>;
  keepPreviousData?: boolean;
  retry?: RetryPolicy;
  retryDelay?: RetryDelay;
  refetchOnWindowFocus?: boolean;
  refetchOnReconnect?: boolean;
  networkMode?: NetworkMode;
  structuralShare?: boolean;
  meta?: QueryMeta;
};

References: InfiniteFetchCtx, RefetchInterval, RetryPolicy, RetryDelay, NetworkMode, QueryMeta

Released under the MIT License.