fix: #239 skip prop proxy if query is manual

This commit is contained in:
Guillaume Chau
2018-05-21 20:55:43 +02:00
parent effec9303f
commit 73c9c2a4e5
2 changed files with 16 additions and 14 deletions
+1 -1
View File
@@ -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,
+15 -13
View File
@@ -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,
})
}
}
}