diff --git a/README.md b/README.md index d3811fb..7815fc2 100644 --- a/README.md +++ b/README.md @@ -743,6 +743,8 @@ apollo: { } ``` +*Note that you can pass an array of subscriptions to `subscribeToMore` to subscribe to multiple subcribtions on this query.* + #### Alternate usage You can access the queries you defined in the `apollo` option with `this.$apollo.queries.`, so it would look like this: diff --git a/src/dollar-apollo.js b/src/dollar-apollo.js index 0ffd244..3a70d7e 100644 --- a/src/dollar-apollo.js +++ b/src/dollar-apollo.js @@ -77,11 +77,21 @@ export class DollarApollo { const smart = this.queries[key] = new SmartQuery(this.vm, key, options, false) smart.autostart() - if (options.subscribeToMore) { - this.addSmartSubscription(key, { - ...options.subscribeToMore, - linkedQuery: smart, - }) + const subs = options.subscribeToMore + if (subs) { + if (Array.isArray(subs)) { + subs.forEach((sub, index) => { + this.addSmartSubscription(`${key}${index}`, { + ...sub, + linkedQuery: smart, + }) + }) + } else { + this.addSmartSubscription(key, { + ...subs, + linkedQuery: smart, + }) + } } return smart