(id = '')
| 4 | import type { QueryClient } from './queryClient' |
| 5 | |
| 6 | export function useQueryClient(id = ''): QueryClient { |
| 7 | // ensures that `inject()` can be used |
| 8 | if (!hasInjectionContext()) { |
| 9 | throw new Error( |
| 10 | 'vue-query hooks can only be used inside setup() function or functions that support injection context.', |
| 11 | ) |
| 12 | } |
| 13 | |
| 14 | const key = getClientKey(id) |
| 15 | const queryClient = inject<QueryClient>(key) |
| 16 | |
| 17 | if (!queryClient) { |
| 18 | throw new Error( |
| 19 | "No 'queryClient' found in Vue context, use 'VueQueryPlugin' to properly initialize the library.", |
| 20 | ) |
| 21 | } |
| 22 | |
| 23 | return queryClient |
| 24 | } |
no test coverage detected
searching dependent graphs…