From bf068cee3182e5cd75b27be106e8d66381feb7a5 Mon Sep 17 00:00:00 2001 From: Guillaume Chau Date: Tue, 29 Aug 2017 13:14:50 +0200 Subject: [PATCH] Revert this.$apollo --- src/index.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 1087024..6bf300d 100644 --- a/src/index.js +++ b/src/index.js @@ -24,7 +24,6 @@ const prepare = function prepare () { if (apollo) { this._apolloQueries = {} this._apolloInitData = {} - this.$apollo = new DollarApollo(this) if (!apollo.$init) { apollo.$init = true @@ -114,6 +113,16 @@ export function install (Vue, options) { return Object.assign(map, merge(toData, fromData)) } + // Lazy creation + Object.defineProperty(Vue.prototype, '$apollo', { + get () { + if (!this._apollo) { + this._apollo = new DollarApollo(this) + } + return this._apollo + }, + }) + Vue.mixin({ // Vue 1.x