Skip to content

API Documentation / @pinia/colada / setInfiniteQueryData

Function: setInfiniteQueryData()

ts
function setInfiniteQueryData<TData, TError, TPageParam>(
   queryCache, 
   key, 
   data): void;

Sets the data of an infinite query entry in the cache. Unlike QueryCache.setQueryData | `queryCache.setQueryData()`, this function properly marks the entry as an infinite query and initializes the infinite query extensions (hasNextPage, hasPreviousPage, etc.).

Use this when you need to set infinite query data before useInfiniteQuery() is mounted (e.g. optimistic updates from a mutation on a different page).

Type Parameters

TData

TData = unknown

TError

TError = { custom: Error; }

TPageParam

TPageParam = unknown

Parameters

queryCache

Store

The query cache instance

key

| EntryKey | EntryKeyTagged<UseInfiniteQueryData<TData, TPageParam>, TError>

The key of the infinite query

data

| UseInfiniteQueryData<TData, TPageParam> | ((oldData) => UseInfiniteQueryData<TData, TPageParam>)

The data to set, or an updater function

Returns

void

Released under the MIT License.