- Use QUERY_KEYS.sourcesInfinite for infinite scroll query key Starting with ['sources', ...] ensures mutations that invalidate ['sources'] will also invalidate the infinite scroll cache - Use httpx.Timeout for chat service with short connect (10s) and long read (600s) timeouts. Prevents 10 min wait on connection errors
34 lines
1.5 KiB
TypeScript
34 lines
1.5 KiB
TypeScript
import { QueryClient } from '@tanstack/react-query'
|
|
|
|
export const queryClient = new QueryClient({
|
|
defaultOptions: {
|
|
queries: {
|
|
staleTime: 5 * 60 * 1000, // 5 minutes
|
|
gcTime: 10 * 60 * 1000, // 10 minutes
|
|
retry: 2,
|
|
refetchOnWindowFocus: false,
|
|
},
|
|
mutations: {
|
|
retry: 1,
|
|
},
|
|
},
|
|
})
|
|
|
|
export const QUERY_KEYS = {
|
|
notebooks: ['notebooks'] as const,
|
|
notebook: (id: string) => ['notebooks', id] as const,
|
|
notes: (notebookId?: string) => ['notes', notebookId] as const,
|
|
note: (id: string) => ['notes', id] as const,
|
|
sources: (notebookId?: string) => ['sources', notebookId] as const,
|
|
sourcesInfinite: (notebookId: string) => ['sources', 'infinite', notebookId] as const,
|
|
source: (id: string) => ['sources', id] as const,
|
|
settings: ['settings'] as const,
|
|
sourceChatSessions: (sourceId: string) => ['source-chat', sourceId, 'sessions'] as const,
|
|
sourceChatSession: (sourceId: string, sessionId: string) => ['source-chat', sourceId, 'sessions', sessionId] as const,
|
|
notebookChatSessions: (notebookId: string) => ['notebook-chat', notebookId, 'sessions'] as const,
|
|
notebookChatSession: (sessionId: string) => ['notebook-chat', 'sessions', sessionId] as const,
|
|
podcastEpisodes: ['podcasts', 'episodes'] as const,
|
|
podcastEpisode: (episodeId: string) => ['podcasts', 'episodes', episodeId] as const,
|
|
episodeProfiles: ['podcasts', 'episode-profiles'] as const,
|
|
speakerProfiles: ['podcasts', 'speaker-profiles'] as const,
|
|
}
|