diff --git a/packages/vue-apollo-composable/src/useMutation.ts b/packages/vue-apollo-composable/src/useMutation.ts index 2e5dc37..e218658 100644 --- a/packages/vue-apollo-composable/src/useMutation.ts +++ b/packages/vue-apollo-composable/src/useMutation.ts @@ -1,6 +1,6 @@ import { DocumentNode } from 'graphql' import { MutationOptions, OperationVariables } from 'apollo-client' -import { ref } from '@vue/composition-api' +import { ref, onBeforeUnmount } from '@vue/composition-api' import { FetchResult } from 'apollo-link' import { useApolloClient } from './useApolloClient' import { ReactiveFunction } from './util/ReactiveFunction' @@ -73,6 +73,10 @@ export function useMutation< } } + onBeforeUnmount(() => { + loading.value = false + }) + return { mutate, loading, diff --git a/packages/vue-apollo-composable/src/useQuery.ts b/packages/vue-apollo-composable/src/useQuery.ts index fb1c2c9..cdcde69 100644 --- a/packages/vue-apollo-composable/src/useQuery.ts +++ b/packages/vue-apollo-composable/src/useQuery.ts @@ -1,4 +1,4 @@ -import { ref, Ref, isRef, computed, watch, onServerPrefetch, onUnmounted, getCurrentInstance } from '@vue/composition-api' +import { ref, Ref, isRef, computed, watch, onServerPrefetch, getCurrentInstance, onBeforeUnmount } from '@vue/composition-api' import Vue from 'vue' import { DocumentNode } from 'graphql' import { @@ -373,7 +373,7 @@ export function useQuery< }) // Teardown - onUnmounted(() => { + onBeforeUnmount(() => { stop() subscribeToMoreItems.length = 0 }) diff --git a/packages/vue-apollo-composable/src/useSubscription.ts b/packages/vue-apollo-composable/src/useSubscription.ts index 6e82db7..6ac466b 100644 --- a/packages/vue-apollo-composable/src/useSubscription.ts +++ b/packages/vue-apollo-composable/src/useSubscription.ts @@ -1,6 +1,6 @@ import { DocumentNode } from 'graphql' import Vue from 'vue' -import { Ref, ref, watch, isRef, onUnmounted, computed, getCurrentInstance } from '@vue/composition-api' +import { Ref, ref, watch, isRef, computed, getCurrentInstance, onBeforeUnmount } from '@vue/composition-api' import { OperationVariables, SubscriptionOptions } from 'apollo-client' import { Observable, Subscription } from 'apollo-client/util/Observable' import { FetchResult } from 'apollo-link' @@ -188,7 +188,7 @@ export function useSubscription < }) // Teardown - onUnmounted(stop) + onBeforeUnmount(stop) return { result,