Skip to content

Commit

Permalink
fix: don't track loading outside of vm, closes #1145
Browse files Browse the repository at this point in the history
  • Loading branch information
Akryum committed Jul 1, 2021
1 parent 9f2d0d7 commit 35940d1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions packages/vue-apollo-composable/src/useMutation.ts
@@ -1,6 +1,6 @@
import { DocumentNode } from 'graphql'
import { MutationOptions, OperationVariables, FetchResult, TypedDocumentNode } from '@apollo/client/core'
import { ref, onBeforeUnmount, isRef, Ref } from 'vue-demi'
import { ref, onBeforeUnmount, isRef, Ref, getCurrentInstance } from 'vue-demi'
import { useApolloClient } from './useApolloClient'
import { ReactiveFunction } from './util/ReactiveFunction'
import { useEventHook } from './util/useEventHook'
Expand Down Expand Up @@ -43,8 +43,9 @@ export function useMutation<
document: DocumentParameter<TResult, TVariables>,
options: OptionsParameter<TResult, TVariables> = {},
): UseMutationReturn<TResult, TVariables> {
const vm = getCurrentInstance()
const loading = ref<boolean>(false)
trackMutation(loading)
vm && trackMutation(loading)
const error = ref<Error | null>(null)
const called = ref<boolean>(false)

Expand Down
2 changes: 1 addition & 1 deletion packages/vue-apollo-composable/src/useSubscription.ts
Expand Up @@ -123,7 +123,7 @@ export function useSubscription <
const errorEvent = useEventHook<Error>()

const loading = ref(false)
trackSubscription(loading)
vm && trackSubscription(loading)

// Apollo Client
const { resolveClient } = useApolloClient()
Expand Down

0 comments on commit 35940d1

Please sign in to comment.