From 73c9c2a4e570f64ca2e1c2b3d6ce165b7703b32b Mon Sep 17 00:00:00 2001 From: Guillaume Chau Date: Mon, 21 May 2018 20:55:43 +0200 Subject: [PATCH] fix: #239 skip prop proxy if query is manual --- src/index.js | 2 +- src/smart-query.js | 28 +++++++++++++++------------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/index.js b/src/index.js index 935c18a..ae8410e 100644 --- a/src/index.js +++ b/src/index.js @@ -56,7 +56,7 @@ const launch = function launch () { options = Object.assign({}, apollo.$query, options) } // Property proxy - if (!hasProperty(this, key) && !hasProperty(this.$props, key) && !hasProperty(this.$data, key)) { + if (!options.manual && !hasProperty(this, key) && !hasProperty(this.$props, key) && !hasProperty(this.$data, key)) { Object.defineProperty(this, key, { get: () => this.$data.$apolloData.data[key], enumerable: true, diff --git a/src/smart-query.js b/src/smart-query.js index 40735b5..f7f1dfc 100644 --- a/src/smart-query.js +++ b/src/smart-query.js @@ -24,19 +24,21 @@ export default class SmartQuery extends SmartApollo { super(vm, key, options, autostart) - this.hasDataField = this.vm.$data.hasOwnProperty(key) - if (this.hasDataField) { - Object.defineProperty(this.vm.$data.$apolloData.data, key, { - get: () => this.vm.$data[key], - enumerable: true, - configurable: true, - }) - } else { - Object.defineProperty(this.vm.$data, key, { - get: () => this.vm.$data.$apolloData.data[key], - enumerable: true, - configurable: true, - }) + if (!options.manual) { + this.hasDataField = this.vm.$data.hasOwnProperty(key) + if (this.hasDataField) { + Object.defineProperty(this.vm.$data.$apolloData.data, key, { + get: () => this.vm.$data[key], + enumerable: true, + configurable: true, + }) + } else { + Object.defineProperty(this.vm.$data, key, { + get: () => this.vm.$data.$apolloData.data[key], + enumerable: true, + configurable: true, + }) + } } }