Open History to see the last commit
1import { queryOptions } from '@tanstack/svelte-query'
2import { contactsAPI } from './api'
3β
4export const contactsQueries = {
5 all: () => ['contacts'] as const,
6 lists: () => [...contactsQueries.all(), 'list'] as const,
7 list: (query: string, customFetch?: typeof fetch) =>
8 queryOptions({
9 queryKey: [...contactsQueries.lists(), query] as const,
10 queryFn: () => contactsAPI(customFetch).getContacts(query),
11 }),
12 detail: (id: string, customFetch?: typeof fetch) =>
13 queryOptions({
14 queryKey: [...contactsQueries.all(), 'detail', id] as const,
15 queryFn: () => contactsAPI(customFetch).getContact(id),
16 }),
17}