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

queries.ts

15 lines547 Bytes

1import { infiniteQueryOptions } from '@tanstack/lit-query'
2import { projectsAPI } from './api'
3​
4export const projectsQueries = {
5 all: () => ['projects'] as const,
6 infinite: () =>
7 infiniteQueryOptions({
8 queryKey: [...projectsQueries.all(), 'infinite'] as const,
9 queryFn: ({ pageParam }) => projectsAPI.getProjects(pageParam),
10 initialPageParam: 0,
11 getPreviousPageParam: (firstPage) => firstPage.previousId ?? undefined,
12 getNextPageParam: (lastPage) => lastPage.nextId ?? undefined,
13 maxPages: 3,
14 }),