Open History to see the last commit
1import { queryOptions, skipToken } from '@tanstack/solid-query'
2import { charactersAPI } from './api'
3β
4export const charactersQueries = {
5 all: () => ['characters'] as const,
6 list: () =>
7 queryOptions({
8 queryKey: [...charactersQueries.all(), 'list'] as const,
9 queryFn: () => charactersAPI.getCharacters(),
10 }),
11 detail: (id: number | undefined) =>
12 queryOptions({
13 queryKey: [...charactersQueries.all(), 'detail', id] as const,
14 queryFn: id ? () => charactersAPI.getCharacter(id) : skipToken,
15 }),
16}