fix: $apolloData

This commit is contained in:
Guillaume Chau
2018-05-07 19:30:01 +02:00
parent 05bb9febab
commit 80c8fe0d23
2 changed files with 9 additions and 7 deletions
+7 -5
View File
@@ -40,11 +40,13 @@ const launch = function launch () {
// watchQuery
for (let key in apollo) {
if (key.charAt(0) !== '$') {
Object.defineProperty(this, key, {
get: () => this.$apolloData.data[key],
enumerable: true,
configurable: true,
})
if (!this.hasOwnProperty(key) && !this.$props.hasOwnProperty(key) && !this.$data.hasOwnProperty(key)) {
Object.defineProperty(this, key, {
get: () => this.$data.$apolloData.data[key],
enumerable: true,
configurable: true,
})
}
this.$apollo.addSmartQuery(key, apollo[key])
}
}
+2 -2
View File
@@ -105,11 +105,11 @@ export default class SmartQuery extends SmartApollo {
// No result
} else if (!this.options.manual) {
if (typeof this.options.update === 'function') {
this.vm.$set(this.vm.$apolloData.data, this.key, this.options.update.call(this.vm, data))
this.vm.$set(this.vm.$data.$apolloData.data, this.key, this.options.update.call(this.vm, data))
} else if (data[this.key] === undefined) {
console.error(`Missing ${this.key} attribute on result`, data)
} else {
this.vm.$set(this.vm.$apolloData.data, this.key, data[this.key])
this.vm.$set(this.vm.$data.$apolloData.data, this.key, data[this.key])
}
} else if (!hasResultCallback) {
console.error(`${this.key} query must have a 'result' hook in manual mode`)