diff --git a/src/dollar-apollo.js b/src/dollar-apollo.js index 5986fff..ca59446 100644 --- a/src/dollar-apollo.js +++ b/src/dollar-apollo.js @@ -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) => { diff --git a/src/index.js b/src/index.js index ed91109..1ea6edc 100644 --- a/src/index.js +++ b/src/index.js @@ -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, {