--- id: infiniteQueryOptions title: infiniteQueryOptions redirect_from: - framework/solid/reference/infiniteQueryOptions --- ## Overview ```ts function infiniteQueryOptions(options: InfiniteQueryOptions & object): ReturnType> & QueryKeyWithDataTag, TError>; function infiniteQueryOptions(options: InfiniteQueryOptions & object): ReturnType> & QueryKeyWithDataTag, TError>; ``` - [`ReturnType` → `ReturnType & QueryKeyWithDataTag`](#call-signature-1): You can generally pass everything to `infiniteQueryOptions` that you can also pass to `useInfiniteQuery`. These options can be shared across hooks and imperative APIs such as `queryClient.infiniteQuery`. `options.queryKey` is required and is the query key to generate options for. - [`ReturnType` → `ReturnType & QueryKeyWithDataTag`](#call-signature-2): You can generally pass everything to `infiniteQueryOptions` that you can also pass to `useInfiniteQuery`. These options can be shared across hooks and imperative APIs such as `queryClient.infiniteQuery`. `options.queryKey` is required and is the query key to generate options for. See also: [Parameters](#parameters-summary) · [Returns](#returns-summary) ## Call Signature ```ts function infiniteQueryOptions(options: InfiniteQueryOptions & object): ReturnType> & QueryKeyWithDataTag, TError>; ``` Defined in: [packages/solid-query/src/infiniteQueryOptions.ts:101](https://github.com/TanStack/query/blob/main/packages/solid-query/src/infiniteQueryOptions.ts#L101) You can generally pass everything to `infiniteQueryOptions` that you can also pass to `useInfiniteQuery`. These options can be shared across hooks and imperative APIs such as `queryClient.infiniteQuery`. `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`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `unknown`\> #### TQueryKey `TQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] #### TPageParam `TPageParam` = `unknown` ### Parameters #### options [`InfiniteQueryOptions`](../interfaces/InfiniteQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> & `object` The [DefinedInitialDataInfiniteOptions](../type-aliases/DefinedInitialDataInfiniteOptions.md) to use — everything you can pass to `useInfiniteQuery`, with `initialData` set. ### Returns `ReturnType`\<[`DefinedInitialDataInfiniteOptions`](../type-aliases/DefinedInitialDataInfiniteOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\>\> & [`QueryKeyWithDataTag`](../type-aliases/QueryKeyWithDataTag.md)\<`TQueryKey`, [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`\>, `TError`\> The same options object, typed so that `queryKey` carries the inferred data type. ### See [useInfiniteQuery](useInfiniteQuery.md) to run an infinite query with these options. ### Example ```tsx import { For } from 'solid-js' import { infiniteQueryOptions, useInfiniteQuery } from '@tanstack/solid-query' const projectsOptions = infiniteQueryOptions({ queryKey: ['projects'], queryFn: ({ pageParam }) => fetchProjects(pageParam), initialPageParam: 0, getNextPageParam: (lastPage) => lastPage.nextId, initialData: { pages: [], pageParams: [] }, }) function Projects() { // `projectsQuery.data` is never `undefined`, thanks to `initialData` — even if a refetch fails, so the // list stays visible alongside the error. const projectsQuery = useInfiniteQuery(() => projectsOptions) return (
{projectsQuery.isError ? Error: {projectsQuery.error.message} : null}
    {(page) => {(p) =>
  • {p.name}
  • }
    }
) } ``` ## Call Signature ```ts function infiniteQueryOptions(options: InfiniteQueryOptions & object): ReturnType> & QueryKeyWithDataTag, TError>; ``` Defined in: [packages/solid-query/src/infiniteQueryOptions.ts:168](https://github.com/TanStack/query/blob/main/packages/solid-query/src/infiniteQueryOptions.ts#L168) You can generally pass everything to `infiniteQueryOptions` that you can also pass to `useInfiniteQuery`. These options can be shared across hooks and imperative APIs such as `queryClient.infiniteQuery`. `options.queryKey` is required and is the query key to generate options for. ### Type Parameters #### TQueryFnData `TQueryFnData` #### TError `TError` = `Error` #### TData `TData` = [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `unknown`\> #### TQueryKey `TQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] #### TPageParam `TPageParam` = `unknown` ### Parameters #### options [`InfiniteQueryOptions`](../interfaces/InfiniteQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> & `object` The [UndefinedInitialDataInfiniteOptions](../type-aliases/UndefinedInitialDataInfiniteOptions.md) to use — everything you can pass to `useInfiniteQuery`. ### Returns `ReturnType`\<[`UndefinedInitialDataInfiniteOptions`](../type-aliases/UndefinedInitialDataInfiniteOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\>\> & [`QueryKeyWithDataTag`](../type-aliases/QueryKeyWithDataTag.md)\<`TQueryKey`, [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`\>, `TError`\> The same options object, typed so that `queryKey` carries the inferred data type. ### See [useInfiniteQuery](useInfiniteQuery.md) to run an infinite query with these options. ### Example A parameterized factory, so the same options object can be reused per `postId`: ```tsx import { For, Match, Switch } from 'solid-js' import { infiniteQueryOptions, useInfiniteQuery } from '@tanstack/solid-query' const commentsOptions = (postId: string) => infiniteQueryOptions({ queryKey: ['post', postId, 'comments'], queryFn: ({ pageParam }) => fetchComments(postId, pageParam), initialPageParam: 0, getNextPageParam: (lastPage) => lastPage.nextId, }) function Comments(props: { postId: string }) { const commentsQuery = useInfiniteQuery(() => commentsOptions(props.postId)) return ( Loading... Error: {commentsQuery.error.message}
    {(page) => {(c) =>
  • {c.text}
  • }
    }
) } ``` ## Parameters ### options [`InfiniteQueryOptions`](../interfaces/InfiniteQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> & `object` The [UndefinedInitialDataInfiniteOptions](../type-aliases/UndefinedInitialDataInfiniteOptions.md) to use — everything you can pass to `useInfiniteQuery`. #### `options` properties Built from [`InfiniteQueryOptions`](../interfaces/InfiniteQueryOptions.md#properties). See the type above for what it changes. ## Returns `ReturnType`\<[`UndefinedInitialDataInfiniteOptions`](../type-aliases/UndefinedInitialDataInfiniteOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\>\> & [`QueryKeyWithDataTag`](../type-aliases/QueryKeyWithDataTag.md)\<`TQueryKey`, [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`\>, `TError`\> The same options object, typed so that `queryKey` carries the inferred data type. ### Result properties Built from [`InfiniteQueryOptions`](../interfaces/InfiniteQueryOptions.md#properties), [`QueryKeyWithDataTag`](../type-aliases/QueryKeyWithDataTag.md#properties). See the type above for what it changes.