apollo icon indicating copy to clipboard operation
apollo copied to clipboard

useLoading not working with Vue 2.7

Open Vahelnir opened this issue 2 years ago • 2 comments

Describe the bug With Vue 2.7 the useQueryLoading() composable (and probably useMutationLoading() and useSubscriptionLoading()) is not getting updated (it stays false).

To Reproduce

  1. https://github.com/Vahelnir/apollo-composable-vue2.7-bug-repro
  2. pnpm install
  3. 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

Vahelnir avatar Jan 03 '23 15:01 Vahelnir

Have you tried with 4.0.0-beta.2 it's working for us.

ebisbe avatar Feb 17 '23 07:02 ebisbe

Yes, and it still doesn't work. I just updated the reproduction repo to use the beta.2.

Vahelnir avatar Feb 17 '23 13:02 Vahelnir