(id = '')
| 24 | * ``` |
| 25 | */ |
| 26 | export function useQueryClient(id = ''): QueryClient { |
| 27 | // ensures that `inject()` can be used |
| 28 | if (!hasInjectionContext()) { |
| 29 | throw new Error( |
| 30 | 'vue-query hooks can only be used inside setup() function or functions that support injection context.', |
| 31 | ) |
| 32 | } |
| 33 | |
| 34 | const key = getClientKey(id) |
| 35 | const queryClient = inject<QueryClient>(key) |
| 36 | |
| 37 | if (!queryClient) { |
| 38 | throw new Error( |
| 39 | "No 'queryClient' found in Vue context, use 'VueQueryPlugin' to properly initialize the library.", |
| 40 | ) |
| 41 | } |
| 42 | |
| 43 | return queryClient |
| 44 | } |
no test coverage detected