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
Is your feature request related to a problem? Please describe.
When using Vue 3.3 we now have the ability to use https://vuejs.org/api/application.html#app-runwithcontext. This is awesome as in vue-router, pinia, etc you can use inject calls without needing to think hard about how things fit together. In other words, there is an active appContext but not an active current instance.
Sadly, currently vue-apollo checks for active instance to see if it even should try an inject or not, which in the cases of vue-router or pinia will fail.
Describe the solution you'd like
I would like to be able to "just" use useQuery (etc) within a defineStore or a navigation guard so for example in a store you could do:
Describe alternatives you've considered
You can "fake" this behavior by using provideApolloClient but this just causes mental overhead for writer and reader of the code.
import{DefaultApolloClient,provideApolloClient,useQuery}from'@vue/apollo-composable';import{defineStore}from'pinia';exportconstusePassportStore=defineStore('passport',()=>{constclient=inject<Parameters<typeofprovideApolloClient>[0]>(DefaultApolloClient);if(client===undefined){throwError('should not happen');}constquery=provideApolloClient(client)(()=>useQuery(SomeDocument));return{data: query.result};});
Additional context
N/A
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
When using Vue 3.3 we now have the ability to use https://vuejs.org/api/application.html#app-runwithcontext. This is awesome as in vue-router, pinia, etc you can use
inject
calls without needing to think hard about how things fit together. In other words, there is an active appContext but not an active current instance.Sadly, currently vue-apollo checks for active instance to see if it even should try an inject or not, which in the cases of vue-router or pinia will fail.
apollo/packages/vue-apollo-composable/src/useApolloClient.ts
Lines 38 to 45 in dfeec67
Describe the solution you'd like
I would like to be able to "just" use useQuery (etc) within a defineStore or a navigation guard so for example in a store you could do:
Describe alternatives you've considered
You can "fake" this behavior by using
provideApolloClient
but this just causes mental overhead for writer and reader of the code.Additional context
N/A
The text was updated successfully, but these errors were encountered: