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

queries.ts

11 lines376 Bytes

1import { queryOptions, skipToken } from '@tanstack/vue-query'
2import { authorsAPI } from './api'
3​
4export const authorsQueries = {
5 all: () => ['authors'] as const,
6 detail: (id: number | undefined) =>
7 queryOptions({
8 queryKey: [...authorsQueries.all(), 'detail', id] as const,
9 queryFn: id === undefined ? skipToken : () => authorsAPI.getAuthor(id),
10 }),