fix: $query

This commit is contained in:
Guillaume Chau
2018-05-24 18:03:19 +02:00
parent 1e9b42af22
commit 4b59520fd5
2 changed files with 13 additions and 7 deletions
+13 -3
View File
@@ -85,13 +85,23 @@ export class DollarApollo {
}
addSmartQuery (key, options) {
options = reapply(options, this.vm)
let finalOptions = reapply(options, this.vm)
const smart = this.queries[key] = new SmartQuery(this.vm, key, options, false)
const apollo = this.vm.$options.apollo
if (apollo && apollo.$query) {
// Also replaces 'undefined' values
for (const key in apollo.$query) {
if (typeof finalOptions[key] === 'undefined') {
finalOptions[key] = apollo.$query[key]
}
}
}
const smart = this.queries[key] = new SmartQuery(this.vm, key, finalOptions, false)
smart.autostart()
if (!this.vm.$isServer) {
const subs = options.subscribeToMore
const subs = finalOptions.subscribeToMore
if (subs) {
if (Array.isArray(subs)) {
subs.forEach((sub, index) => {
-4
View File
@@ -51,10 +51,6 @@ const launch = function launch () {
for (let key in apollo) {
if (key.charAt(0) !== '$') {
let options = apollo[key]
// Default options from component
if (apollo.$query) {
options = Object.assign({}, apollo.$query, options)
}
// Property proxy
if (!options.manual && !hasProperty(this, key) && !hasProperty(this.$props, key) && !hasProperty(this.$data, key)) {
Object.defineProperty(this, key, {