From d6d4da16d56233e1c6fb4df261cda4a0b9f665d4 Mon Sep 17 00:00:00 2001 From: Guillaume Chau Date: Mon, 2 May 2022 16:32:53 +0200 Subject: [PATCH] fix: $apollo null error if smar obj is destroyed but has throttled/debounced calls --- packages/vue-apollo-option/src/smart-apollo.js | 1 + packages/vue-apollo-option/src/smart-query.js | 2 ++ packages/vue-apollo-option/src/smart-subscription.js | 2 ++ 3 files changed, 5 insertions(+) diff --git a/packages/vue-apollo-option/src/smart-apollo.js b/packages/vue-apollo-option/src/smart-apollo.js index daca81f..54cd543 100644 --- a/packages/vue-apollo-option/src/smart-apollo.js +++ b/packages/vue-apollo-option/src/smart-apollo.js @@ -98,6 +98,7 @@ export default class SmartApollo { const queryCb = this.initialOptions[prop].bind(this.vm) this.options[prop] = queryCb() let cb = query => { + if (this._destroyed) return this.options[prop] = query this.refresh() } diff --git a/packages/vue-apollo-option/src/smart-query.js b/packages/vue-apollo-option/src/smart-query.js index 2242dda..bda4b5d 100644 --- a/packages/vue-apollo-option/src/smart-query.js +++ b/packages/vue-apollo-option/src/smart-query.js @@ -94,6 +94,8 @@ export default class SmartQuery extends SmartApollo { } executeApollo (variables) { + if (this._destroyed) return + const variablesJson = JSON.stringify(variables) if (this.sub) { diff --git a/packages/vue-apollo-option/src/smart-subscription.js b/packages/vue-apollo-option/src/smart-subscription.js index 474feed..eb7e98b 100644 --- a/packages/vue-apollo-option/src/smart-subscription.js +++ b/packages/vue-apollo-option/src/smart-subscription.js @@ -28,6 +28,8 @@ export default class SmartSubscription extends SmartApollo { } executeApollo (variables) { + if (this._destroyed) return + const variablesJson = JSON.stringify(variables) if (this.sub) { // do nothing if subscription is already running using exactly the same variables