Open History to see the last commit
1import { queryOptions } from '@tanstack/react-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: (characterId: string) =>
12 queryOptions({
13 queryKey: [...charactersQueries.all(), 'detail', characterId] as const,
14 queryFn: () => charactersAPI.getCharacter(characterId),
15 }),
16}