apollo
apollo copied to clipboard
useLoading not working with Vue 2.7
Describe the bug
With Vue 2.7 the useQueryLoading()
composable (and probably useMutationLoading()
and useSubscriptionLoading()
) is not getting updated (it stays false).
To Reproduce
- https://github.com/Vahelnir/apollo-composable-vue2.7-bug-repro
-
pnpm install
-
pnpm run dev
Expected behavior
useQueryLoading()
has to be true while some local queries are loading, and false when they are done.
Versions vue: 2.7.14 vue-apollo: 4.0.0-alpha.19 & 4.0.0-beta.1 @apollo/client: 3.7.3
Additional context
The implementation of getCurrentInstance()
seems to be the cause.
It is creating a new object containing the proxy everytime it is called (currentInstance.ts#L13).
Since the result of getCurrentInstance()
is directly being used as a key in the appTracking.components
map, the tracking object is recreated everytime. https://github.com/vuejs/apollo/blob/372892855d76622128ac560e8fadc689c50675bc/packages/vue-apollo-composable/src/util/loadingTracking.ts#L52
Not sure if it has to be fixed here nor how to properly fix this only for Vue 2.7
Have you tried with 4.0.0-beta.2
it's working for us.
Yes, and it still doesn't work. I just updated the reproduction repo to use the beta.2.