* docs(*): add parameter and result property tables to reference function pages and an overview to overloaded ones * docs(*): link to the base type's properties when a parameter or result type has no property table * docs(framework/*/reference): regenerate reference docs * docs(framework/*/reference): regenerate reference docs * chore(scripts/generate-docs): restore the 'dirname' import that the merge dropped * docs(framework/*/reference): regenerate reference docs * docs(scripts/generate-docs): label overloads in the overview with their declared parameter and return types * docs(framework/*/reference): regenerate reference docs * docs(scripts/generate-docs): convert declared intersection types from the source so signatures keep their alias names * docs(framework/*/reference): regenerate reference docs * docs(scripts/generate-docs): reword a comment to avoid the unknown word 'inlines' * docs(scripts/generate-docs): skip a parameter table on overloaded pages when its heading is missing
13 KiB
| id | title |
|---|---|
| infiniteQueryOptions | infiniteQueryOptions |
Overview
function infiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>(options: DefinedInitialDataInfiniteOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>): DefinedInitialDataInfiniteOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam> & QueryKeyWithDataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>;
function infiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>(options: UnusedSkipTokenInfiniteOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>): UnusedSkipTokenInfiniteOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam> & QueryKeyWithDataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>;
function infiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>(options: UndefinedInitialDataInfiniteOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>): UndefinedInitialDataInfiniteOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam> & QueryKeyWithDataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>;
DefinedInitialDataInfiniteOptions→DefinedInitialDataInfiniteOptions & QueryKeyWithDataTag: You can generally pass everything toinfiniteQueryOptionsthat you can also pass toinjectInfiniteQuery. These options can be shared across functions and imperative APIs such asqueryClient.fetchInfiniteQuery.options.queryKeyis required and is the query key to generate options for.UnusedSkipTokenInfiniteOptions→UnusedSkipTokenInfiniteOptions & QueryKeyWithDataTag: You can generally pass everything toinfiniteQueryOptionsthat you can also pass toinjectInfiniteQuery. These options can be shared across functions and imperative APIs such asqueryClient.fetchInfiniteQuery.options.queryKeyis required and is the query key to generate options for.UndefinedInitialDataInfiniteOptions→UndefinedInitialDataInfiniteOptions & QueryKeyWithDataTag: You can generally pass everything toinfiniteQueryOptionsthat you can also pass toinjectInfiniteQuery. These options can be shared across functions and imperative APIs such asqueryClient.fetchInfiniteQuery.options.queryKeyis required and is the query key to generate options for.
See also: Parameters · Returns
Call Signature
function infiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>(options: DefinedInitialDataInfiniteOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>): DefinedInitialDataInfiniteOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam> & QueryKeyWithDataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>;
Defined in: packages/angular-query-experimental/src/infinite-query-options.ts:176
You can generally pass everything to infiniteQueryOptions that you can also pass to
injectInfiniteQuery. These options can be shared across functions and imperative APIs such as
queryClient.fetchInfiniteQuery. options.queryKey is required and is the query key to generate options
for.
This overload is selected when initialData is set.
Type Parameters
TQueryFnData
TQueryFnData
TError
TError = Error
TData
TData = InfiniteData<TQueryFnData, unknown>
TQueryKey
TQueryKey extends readonly unknown[] = readonly unknown[]
TPageParam
TPageParam = unknown
Parameters
options
DefinedInitialDataInfiniteOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>
The DefinedInitialDataInfiniteOptions to use — everything you can pass to
injectInfiniteQuery, with initialData set.
Returns
DefinedInitialDataInfiniteOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam> & QueryKeyWithDataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>
The same options object, typed so that queryKey carries the inferred data type.
Remarks
See injectInfiniteQuery for examples that fetch further pages, from a button click or automatically as the user scrolls.
See
injectInfiniteQuery to run an infinite query with these options.
Example
import { infiniteQueryOptions, injectInfiniteQuery } from '@tanstack/angular-query-experimental'
export const projectsOptions = infiniteQueryOptions({
queryKey: ['projects'],
queryFn: ({ pageParam }) => fetchProjects(pageParam),
initialPageParam: 0,
getNextPageParam: (lastPage) => lastPage.nextId,
initialData: { pages: [], pageParams: [] },
})
@Component({
selector: 'projects',
template: `
<!-- `projectsQuery.data()` is never `undefined`, thanks to `initialData` — even if a
refetch fails, so the list stays visible alongside the error. -->
<ul>
@for (page of projectsQuery.data().pages; track $index) {
@for (project of page.projects; track project.id) {
<li>{{ project.name }}</li>
}
}
</ul>
`,
})
export class Projects {
readonly projectsQuery = injectInfiniteQuery(() => projectsOptions)
}
Call Signature
function infiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>(options: UnusedSkipTokenInfiniteOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>): UnusedSkipTokenInfiniteOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam> & QueryKeyWithDataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>;
Defined in: packages/angular-query-experimental/src/infinite-query-options.ts:247
You can generally pass everything to infiniteQueryOptions that you can also pass to
injectInfiniteQuery. These options can be shared across functions and imperative APIs such as
queryClient.fetchInfiniteQuery. options.queryKey is required and is the query key to generate options
for.
Type Parameters
TQueryFnData
TQueryFnData
TError
TError = Error
TData
TData = InfiniteData<TQueryFnData, unknown>
TQueryKey
TQueryKey extends readonly unknown[] = readonly unknown[]
TPageParam
TPageParam = unknown
Parameters
options
UnusedSkipTokenInfiniteOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>
The UnusedSkipTokenInfiniteOptions to use — everything you can pass to
injectInfiniteQuery.
Returns
UnusedSkipTokenInfiniteOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam> & QueryKeyWithDataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>
The same options object, typed so that queryKey carries the inferred data type.
Remarks
See injectInfiniteQuery for examples that fetch further pages, from a button click or automatically as the user scrolls.
See
injectInfiniteQuery to run an infinite query with these options.
Example
A parameterized factory, so the same options object can be reused per postId:
import { infiniteQueryOptions, injectInfiniteQuery } from '@tanstack/angular-query-experimental'
export const commentsOptions = (postId: string) =>
infiniteQueryOptions({
queryKey: ['post', postId, 'comments'],
queryFn: ({ pageParam }) => fetchComments(postId, pageParam),
initialPageParam: 0,
getNextPageParam: (lastPage) => lastPage.nextId,
})
@Component({
selector: 'comments',
template: `
@if (commentsQuery.isPending()) {
Loading...
} @else if (commentsQuery.isError()) {
<span>Error: {{ commentsQuery.error()?.message }}</span>
} @else {
<ul>
@for (page of commentsQuery.data().pages; track $index) {
@for (comment of page.comments; track comment.id) {
<li>{{ comment.text }}</li>
}
}
</ul>
}
`,
})
export class Comments {
readonly postId = signal('1')
readonly commentsQuery = injectInfiniteQuery(() => commentsOptions(this.postId()))
}
Call Signature
function infiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>(options: UndefinedInitialDataInfiniteOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>): UndefinedInitialDataInfiniteOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam> & QueryKeyWithDataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>;
Defined in: packages/angular-query-experimental/src/infinite-query-options.ts:318
You can generally pass everything to infiniteQueryOptions that you can also pass to
injectInfiniteQuery. These options can be shared across functions and imperative APIs such as
queryClient.fetchInfiniteQuery. options.queryKey is required and is the query key to generate options
for.
Type Parameters
TQueryFnData
TQueryFnData
TError
TError = Error
TData
TData = InfiniteData<TQueryFnData, unknown>
TQueryKey
TQueryKey extends readonly unknown[] = readonly unknown[]
TPageParam
TPageParam = unknown
Parameters
options
UndefinedInitialDataInfiniteOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>
The UndefinedInitialDataInfiniteOptions to use — everything you can pass to
injectInfiniteQuery.
Returns
UndefinedInitialDataInfiniteOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam> & QueryKeyWithDataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>
The same options object, typed so that queryKey carries the inferred data type.
Remarks
See injectInfiniteQuery for examples that fetch further pages (from a button click or
automatically as the user scrolls) and that use skipToken to disable the query until postId is set.
See
injectInfiniteQuery to run an infinite query with these options.
Example
A parameterized factory, so the same options object can be reused per postId:
import { infiniteQueryOptions, injectInfiniteQuery } from '@tanstack/angular-query-experimental'
export const commentsOptions = (postId: string) =>
infiniteQueryOptions({
queryKey: ['post', postId, 'comments'],
queryFn: ({ pageParam }) => fetchComments(postId, pageParam),
initialPageParam: 0,
getNextPageParam: (lastPage) => lastPage.nextId,
})
@Component({
selector: 'comments',
template: `
@if (commentsQuery.isPending()) {
Loading...
} @else if (commentsQuery.isError()) {
<span>Error: {{ commentsQuery.error()?.message }}</span>
} @else {
<ul>
@for (page of commentsQuery.data().pages; track $index) {
@for (comment of page.comments; track comment.id) {
<li>{{ comment.text }}</li>
}
}
</ul>
}
`,
})
export class Comments {
readonly postId = signal('1')
readonly commentsQuery = injectInfiniteQuery(() => commentsOptions(this.postId()))
}
Parameters
options
UndefinedInitialDataInfiniteOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>
The UndefinedInitialDataInfiniteOptions to use — everything you can pass to
injectInfiniteQuery.
options properties
Built from CreateInfiniteQueryOptions. See the type above for what it changes.
Returns
UndefinedInitialDataInfiniteOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam> & QueryKeyWithDataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>
The same options object, typed so that queryKey carries the inferred data type.
Result properties
Built from CreateInfiniteQueryOptions, QueryKeyWithDataTag. See the type above for what it changes.