diff --git a/packages/vue-apollo-composable/src/useSubscription.ts b/packages/vue-apollo-composable/src/useSubscription.ts index 034618b..627f50e 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 } from '@vue/composition-api' +import { Ref, ref, watch, isRef, onUnmounted, computed, getCurrentInstance } from '@vue/composition-api' import { OperationVariables, SubscriptionOptions } from 'apollo-client' import { Observable, Subscription } from 'apollo-client/util/Observable' import { FetchResult } from 'apollo-link' @@ -30,6 +30,10 @@ export function useSubscription < variables: TVariables | Ref | ReactiveFunction = null, options: UseSubscriptionOptions | Ref> | ReactiveFunction> = null ) { + // Is on server? + const vm = getCurrentInstance() + const isServer = vm.$isServer + if (variables == null) variables = ref() if (!options) options = {} const documentRef = paramToRef(document) @@ -52,7 +56,7 @@ export function useSubscription < let started = false function start () { - if (started || !isEnabled.value) return + if (started || !isEnabled.value || isServer) return started = true loading.value = true