| 12 | * @returns The `QueryClient` set on context, whether by `QueryClientProvider` or {@link setQueryClientContext}. |
| 13 | */ |
| 14 | export const getQueryClientContext = (): QueryClient => { |
| 15 | const client = getContext<QueryClient | undefined>(_contextKey) |
| 16 | if (!client) { |
| 17 | throw new Error( |
| 18 | 'No QueryClient was found in Svelte context. Did you forget to wrap your component with QueryClientProvider?', |
| 19 | ) |
| 20 | } |
| 21 | |
| 22 | return client |
| 23 | } |
| 24 | |
| 25 | /** |
| 26 | * Sets a `QueryClient` on Svelte's context, so it can be read with {@link getQueryClientContext} (or |