Skip to content

Commit d329d4d

Browse files
authored
fix: improved pinia support (#1571)
1 parent 7f3cf7d commit d329d4d

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

packages/vue-apollo-composable/src/useQuery.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
watch,
77
onServerPrefetch,
88
getCurrentScope,
9+
getCurrentInstance,
910
onScopeDispose,
1011
nextTick,
1112
shallowRef,
@@ -152,6 +153,7 @@ export function useQueryImpl<
152153
lazy = false,
153154
): UseQueryReturn<TResult, TVariables> {
154155
const currentScope = getCurrentScope()
156+
const currentInstance = getCurrentInstance()
155157

156158
const currentOptions = ref<UseQueryOptions<TResult, TVariables>>()
157159

@@ -200,7 +202,7 @@ export function useQueryImpl<
200202
firstRejectError = undefined
201203
}
202204

203-
currentScope && onServerPrefetch?.(() => {
205+
currentInstance && onServerPrefetch?.(() => {
204206
if (!isEnabled.value || (isServer && currentOptions.value?.prefetch === false)) return
205207

206208
return new Promise<void>((resolve, reject) => {

packages/vue-apollo-composable/src/util/loadingTracking.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Ref, watch, onUnmounted, ref, getCurrentScope, onScopeDispose } from 'vue-demi'
1+
import { Ref, watch, ref, getCurrentScope, onScopeDispose } from 'vue-demi'
22
import { isServer } from './env.js'
33

44
import type { EffectScope } from 'vue-demi'
@@ -36,7 +36,7 @@ export function getCurrentTracking () {
3636
subscriptions: ref(0),
3737
})
3838
// Cleanup
39-
onUnmounted(() => {
39+
onScopeDispose(() => {
4040
globalTracking.components.delete(currentScope)
4141
})
4242
} else {

0 commit comments

Comments
 (0)