You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I encountered this issue when trying to use useQuery in a composable. Maybe I'm missing something too. Otherwise, it seems to me that it would contradict Composition API pattern.
Could you use useClientHandle instead? This one works outside components, but it is intended for one shot queries...
This is due to the use of getCurrentInstance as vue router isnt a component instance.
If urql-vue bumps its vue dependency to vue3.3+ they'd be able to use hasInjectionContext (docs) as newer vue router versions use app.runWithContext (docs).
Bumping the dependency should also allow for some cleanup as vue3.3 also includes MaybeRef & MaybeRefOrGetter which I think urql-vue implements manually at the moment.
I also had a look at @tanstack/vue-query and they use getCurrentScope() so that could also be an option but the vue docs dont mention which version its available from.
Describe the bug
The setup: There's a pinia store that is used in a router guard, the store uses
useQuery
composable from@urql/vue
Because it tried to access vue instance in router guard the app returns the following error:
As far as I can see the error comes from
urql/packages/vue-urql/src/useClient.ts
Line 104 in 25d114d
Am I doing something wrong?
Reproduction
https://stackblitz.com/edit/vitejs-vite-kudyigng
Urql version
@urql/vue v1.4.2
Validations
The text was updated successfully, but these errors were encountered: