diff --git a/packages/vue-apollo-composable/src/useQuery.ts b/packages/vue-apollo-composable/src/useQuery.ts index c2e1178..2a56917 100644 --- a/packages/vue-apollo-composable/src/useQuery.ts +++ b/packages/vue-apollo-composable/src/useQuery.ts @@ -323,9 +323,14 @@ export function useQuery< // Applying variables let currentVariables: TVariables - watch(variablesRef, value => { - currentVariables = value - restart() + let currentVariablesSerialized: string + watch(variablesRef, (value, oldValue) => { + const serialized = JSON.stringify(value) + if (serialized !== currentVariablesSerialized) { + currentVariables = value + restart() + } + currentVariablesSerialized = serialized }, { deep: true, }) diff --git a/packages/vue-apollo-composable/src/useSubscription.ts b/packages/vue-apollo-composable/src/useSubscription.ts index 14c9072..79b6f58 100644 --- a/packages/vue-apollo-composable/src/useSubscription.ts +++ b/packages/vue-apollo-composable/src/useSubscription.ts @@ -211,9 +211,14 @@ export function useSubscription < // Applying variables let currentVariables: TVariables - watch(variablesRef, value => { - currentVariables = value - restart() + let currentVariablesSerialized: string + watch(variablesRef, (value, oldValue) => { + const serialized = JSON.stringify(value) + if (serialized !== currentVariablesSerialized) { + currentVariables = value + restart() + } + currentVariablesSerialized = serialized }, { deep: true, })