diff --git a/package.json b/package.json index d7ceaac..ae5285d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vue-apollo", - "version": "1.0.0-beta11", + "version": "1.0.0-beta.12", "description": "Vue apollo integration", "main": "index.js", "scripts": { diff --git a/src/vue-plugin.js b/src/vue-plugin.js index 842caaf..fc8b35d 100644 --- a/src/vue-plugin.js +++ b/src/vue-plugin.js @@ -159,7 +159,15 @@ class DollarApollo { function prepare() { this._apolloSubscriptions = []; - this.$apollo = new DollarApollo(this); + // Lazy creation + Object.defineProperty(this, '$apollo', { + get: () => { + if(!this._apollo) { + this._apollo = new DollarApollo(this); + } + return this._apollo; + } + }); } function launch() { @@ -201,8 +209,8 @@ module.exports = { sub.unsubscribe(); }); this._apolloSubscriptions = null; - if (this.$apollo) { - this.$apollo = null; + if (this._apollo) { + this._apollo = null; } }