Skip to content

Commit

Permalink
Version bump
Browse files Browse the repository at this point in the history
  • Loading branch information
Guillaume Chau committed Aug 28, 2017
1 parent d07900c commit 268f33b
Show file tree
Hide file tree
Showing 4 changed files with 158 additions and 70 deletions.
112 changes: 78 additions & 34 deletions dist/vue-apollo.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -2612,6 +2612,19 @@ var SmartApollo = function () {
value: function nextResult() {
throw new Error('Not implemented');
}
}, {
key: 'errorHandler',
value: function errorHandler() {
var _options$error, _vm$$apollo$error, _vm$$apollo$provider$;

for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}

this.options.error && (_options$error = this.options.error).call.apply(_options$error, [this.vm].concat(args));
this.vm.$apollo.error && (_vm$$apollo$error = this.vm.$apollo.error).call.apply(_vm$$apollo$error, [this.vm].concat(args));
this.vm.$apollo.provider.errorHandler && (_vm$$apollo$provider$ = this.vm.$apollo.provider.errorHandler).call.apply(_vm$$apollo$provider$, [this.vm].concat(args));
}
}, {
key: 'catchError',
value: function catchError(error) {
Expand Down Expand Up @@ -2654,9 +2667,7 @@ var SmartApollo = function () {
}
}

if (typeof this.options.error === 'function') {
this.options.error.call(this.vm, error);
}
this.errorHandler(error);
}
}, {
key: 'destroy',
Expand Down Expand Up @@ -2807,16 +2818,28 @@ var SmartQuery = function (_SmartApollo) {
get(SmartQuery.prototype.__proto__ || Object.getPrototypeOf(SmartQuery.prototype), 'catchError', this).call(this, error);
this.loadingDone();
}
}, {
key: 'watchLoading',
value: function watchLoading() {
var _options$watchLoading, _vm$$apollo$watchLoad, _vm$$apollo$provider$2;

for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
args[_key2] = arguments[_key2];
}

this.options.watchLoading && (_options$watchLoading = this.options.watchLoading).call.apply(_options$watchLoading, [this.vm].concat(args));
this.vm.$apollo.watchLoading && (_vm$$apollo$watchLoad = this.vm.$apollo.watchLoading).call.apply(_vm$$apollo$watchLoad, [this.vm].concat(args));
this.vm.$apollo.provider.watchLoading && (_vm$$apollo$provider$2 = this.vm.$apollo.provider.watchLoading).call.apply(_vm$$apollo$provider$2, [this.vm].concat(args));
}
}, {
key: 'applyLoadingModifier',
value: function applyLoadingModifier(value) {
if (this.options.loadingKey) {
this.vm[this.options.loadingKey] += value;
var loadingKey = this.loadingKey;
if (loadingKey && typeof this.vm[loadingKey] === 'number') {
this.vm[loadingKey] += value;
}

if (this.options.watchLoading) {
this.options.watchLoading.call(this.vm, value === 1, value);
}
this.watchLoading(value === 1, value);
}
}, {
key: 'loadingDone',
Expand Down Expand Up @@ -2909,6 +2932,11 @@ var SmartQuery = function (_SmartApollo) {
return (_observer4 = this.observer).stopPolling.apply(_observer4, arguments);
}
}
}, {
key: 'loadingKey',
get: function get$$1() {
return this.options.loadingKey || this.vm.$apollo.loadingKey;
}
}]);
return SmartQuery;
}(SmartApollo);
Expand All @@ -2923,8 +2951,8 @@ var SmartSubscription = function (_SmartApollo2) {

classCallCheck(this, SmartSubscription);

for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
args[_key3] = arguments[_key3];
}

return _ret = (_temp = (_this6 = possibleConstructorReturn(this, (_ref = SmartSubscription.__proto__ || Object.getPrototypeOf(SmartSubscription)).call.apply(_ref, [this].concat(args))), _this6), _this6.type = 'subscription', _this6.vueApolloSpecialKeys = ['variables', 'result', 'error', 'throttle', 'debounce', 'linkedQuery'], _temp), possibleConstructorReturn(_this6, _ret);
Expand Down Expand Up @@ -2976,6 +3004,8 @@ var DollarApollo = function () {
this.queries = {};
this.subscriptions = {};
this.client = undefined;
this.loadingKey = undefined;
this.error = undefined;
}

createClass(DollarApollo, [{
Expand Down Expand Up @@ -3168,6 +3198,9 @@ var ApolloProvider$1 = function () {
}
this.clients = options.clients || {};
this.clients.defaultClient = this.defaultClient = options.defaultClient;
this.defaultOptions = options.defaultOptions;
this.watchLoading = options.watchLoading;
this.errorHandler = options.errorHandler;

this.prefetchQueries = [];
}
Expand Down Expand Up @@ -3286,16 +3319,19 @@ var ApolloProvider$1 = function () {
result = prefetch;
}

var optVariables = queryOptions.variables;

if (!result) {
return Promise.resolve();
} else if (prefetchType === 'boolean' && typeof optVariables !== 'undefined') {
// Reuse `variables` option with `prefetch: true`
if (typeof optVariables === 'function') {
variables = optVariables.call(context);
} else if (prefetchType === 'boolean') {
var optVariables = queryOptions.variables;
if (typeof optVariables !== 'undefined') {
// Reuse `variables` option with `prefetch: true`
if (typeof optVariables === 'function') {
variables = optVariables.call(context);
} else {
variables = optVariables;
}
} else {
variables = optVariables;
variables = undefined;
}
} else {
variables = result;
Expand Down Expand Up @@ -3351,18 +3387,32 @@ function willPrefetch(component) {
var keywords = ['$subscribe'];

var prepare = function prepare() {
var apolloProvider = void 0;
if (this.$options.apolloProvider) {
this._apolloProvider = this.$options.apolloProvider;
apolloProvider = this._apolloProvider = this.$options.apolloProvider;
} else {
apolloProvider = this.$root._apolloProvider;
}

if (this._apolloPrepared) return;
this._apolloPrepared = true;

// Prepare properties
var apollo = this.$options.apollo;

if (apollo) {
this._apolloQueries = {};
this._apolloInitData = {};
this.$apollo = new DollarApollo(this);

if (!apollo.$init) {
apollo.$init = true;

// Default options applied to `apollo` options
if (apolloProvider.defaultOptions) {
apollo = this.$options.apollo = Object.assign({}, apolloProvider.defaultOptions, apollo);
}
}

// watchQuery
for (var key in apollo) {
Expand All @@ -3378,14 +3428,23 @@ var launch = function launch() {
if (this._apolloLaunched) return;
this._apolloLaunched = true;

var apollo = this.$options.apollo;
if (apollo) {
defineReactiveSetter(this.$apollo, 'skipAll', apollo.$skipAll);
defineReactiveSetter(this.$apollo, 'skipAllQueries', apollo.$skipAllQueries);
defineReactiveSetter(this.$apollo, 'skipAllSubscriptions', apollo.$skipAllSubscriptions);
defineReactiveSetter(this.$apollo, 'client', apollo.$client);
defineReactiveSetter(this.$apollo, 'loadingKey', apollo.$loadingKey);
defineReactiveSetter(this.$apollo, 'error', apollo.$error);
}

if (this._apolloQueries) {
// watchQuery
for (var key in this._apolloQueries) {
this.$apollo.addSmartQuery(key, this._apolloQueries[key]);
}
}

var apollo = this.$options.apollo;
if (apollo) {
if (apollo.subscribe) {
Globals.Vue.util.warn('vue-apollo -> `subscribe` option is deprecated. Use the `$subscribe` option instead.');
Expand All @@ -3396,11 +3455,6 @@ var launch = function launch() {
this.$apollo.addSmartSubscription(_key, apollo.$subscribe[_key]);
}
}

defineReactiveSetter(this.$apollo, 'skipAll', apollo.$skipAll);
defineReactiveSetter(this.$apollo, 'skipAllQueries', apollo.$skipAllQueries);
defineReactiveSetter(this.$apollo, 'skipAllSubscriptions', apollo.$skipAllSubscriptions);
defineReactiveSetter(this.$apollo, 'client', apollo.$client);
}
};

Expand Down Expand Up @@ -3438,16 +3492,6 @@ function install(Vue, options) {
return Object.assign(map, merge(toData, fromData));
};

// Lazy creation
Object.defineProperty(Vue.prototype, '$apollo', {
get: function get() {
if (!this._apollo) {
this._apollo = new DollarApollo(this);
}
return this._apollo;
}
});

Vue.mixin({

// Vue 1.x
Expand Down
Loading

0 comments on commit 268f33b

Please sign in to comment.