Skip to content

Commit

Permalink
fix: improved pinia support (#1571)
Browse files Browse the repository at this point in the history
  • Loading branch information
nickmessing authored Aug 23, 2024
1 parent 7f3cf7d commit d329d4d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion packages/vue-apollo-composable/src/useQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
watch,
onServerPrefetch,
getCurrentScope,
getCurrentInstance,
onScopeDispose,
nextTick,
shallowRef,
Expand Down Expand Up @@ -152,6 +153,7 @@ export function useQueryImpl<
lazy = false,
): UseQueryReturn<TResult, TVariables> {
const currentScope = getCurrentScope()
const currentInstance = getCurrentInstance()

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

Expand Down Expand Up @@ -200,7 +202,7 @@ export function useQueryImpl<
firstRejectError = undefined
}

currentScope && onServerPrefetch?.(() => {
currentInstance && onServerPrefetch?.(() => {
if (!isEnabled.value || (isServer && currentOptions.value?.prefetch === false)) return

return new Promise<void>((resolve, reject) => {
Expand Down
4 changes: 2 additions & 2 deletions packages/vue-apollo-composable/src/util/loadingTracking.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Ref, watch, onUnmounted, ref, getCurrentScope, onScopeDispose } from 'vue-demi'
import { Ref, watch, ref, getCurrentScope, onScopeDispose } from 'vue-demi'
import { isServer } from './env.js'

import type { EffectScope } from 'vue-demi'
Expand Down Expand Up @@ -36,7 +36,7 @@ export function getCurrentTracking () {
subscriptions: ref(0),
})
// Cleanup
onUnmounted(() => {
onScopeDispose(() => {
globalTracking.components.delete(currentScope)
})
} else {
Expand Down

0 comments on commit d329d4d

Please sign in to comment.