From 8e369c71b106f76efcacf0cd5d09cd4ba80a6ea9 Mon Sep 17 00:00:00 2001 From: Guillaume Chau Date: Sun, 2 Sep 2018 14:32:51 +0200 Subject: [PATCH] chore: v3.0.0-beta.21 --- dist/vue-apollo.esm.js | 2 +- dist/vue-apollo.min.js | 2 +- dist/vue-apollo.umd.js | 2 +- package.json | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dist/vue-apollo.esm.js b/dist/vue-apollo.esm.js index 972f2983..c524320e 100644 --- a/dist/vue-apollo.esm.js +++ b/dist/vue-apollo.esm.js @@ -1896,7 +1896,7 @@ function install(Vue, options) { ApolloProvider.install = install; // eslint-disable-next-line no-undef -ApolloProvider.version = "3.0.0-beta.20"; +ApolloProvider.version = "3.0.0-beta.21"; // Apollo provider var ApolloProvider$1 = ApolloProvider; diff --git a/dist/vue-apollo.min.js b/dist/vue-apollo.min.js index cf8dd674..50ea98bb 100644 --- a/dist/vue-apollo.min.js +++ b/dist/vue-apollo.min.js @@ -1 +1 @@ -var VueApollo=function(t){"use strict";function e(t,e,i,o){var r,n=0;return"boolean"!=typeof e&&(o=i,i=e,e=void 0),function(){var s=this,a=Number(new Date)-n,l=arguments;function u(){n=Number(new Date),i.apply(s,l)}o&&!r&&u(),r&&clearTimeout(r),void 0===o&&a>t?u():!0!==e&&(r=setTimeout(o?function(){r=void 0}:u,void 0===o?t-a:t))}}var i,o=Object.freeze({throttle:e,debounce:function(t,i,o){return void 0===o?e(t,i,!1):e(t,o,!1!==i)}}),r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},s=function(){function t(t,e){for(var i=0;i3&&void 0!==arguments[3])||arguments[3];n(this,t),this.type=null,this.vueApolloSpecialKeys=[],this.vm=e,this.key=i,this.initialOptions=o,this.options=Object.assign({},o),this._skip=!1,this._watchers=[],this._destroyed=!1,this.vm.$isServer&&(this.options.fetchPolicy="cache-first"),r&&this.autostart()}return s(t,[{key:"autostart",value:function(){"function"==typeof this.options.skip?this._skipWatcher=this.vm.$watch(this.options.skip.bind(this.vm),this.skipChanged.bind(this),{immediate:!0,deep:this.options.deep}):this.options.skip?this._skip=!0:this.start()}},{key:"skipChanged",value:function(t,e){t!==e&&(this.skip=t)}},{key:"refresh",value:function(){this._skip||(this.stop(),this.start())}},{key:"start",value:function(){var t=this;if(this.starting=!0,"function"==typeof this.initialOptions.query){var e=this.initialOptions.query.bind(this.vm);this.options.query=e(),this._watchers.push(this.vm.$watch(e,function(e){t.options.query=e,t.refresh()},{deep:this.options.deep}))}if("function"==typeof this.initialOptions.document){var i=this.initialOptions.document.bind(this.vm);this.options.document=i(),this._watchers.push(this.vm.$watch(i,function(e){t.options.document=e,t.refresh()},{deep:this.options.deep}))}if("function"==typeof this.initialOptions.context){var o=this.initialOptions.context.bind(this.vm);this.options.context=o(),this._watchers.push(this.vm.$watch(o,function(e){t.options.context=e,t.refresh()},{deep:this.options.deep}))}if("function"==typeof this.options.variables){var r=this.executeApollo.bind(this);r=this.options.throttle?f(r,this.options.throttle):r,r=this.options.debounce?v(r,this.options.debounce):r,this._watchers.push(this.vm.$watch(function(){return t.options.variables.call(t.vm)},r,{immediate:!0,deep:this.options.deep}))}else this.executeApollo(this.options.variables)}},{key:"stop",value:function(){var t=!0,e=!1,i=void 0;try{for(var o,r=this._watchers[Symbol.iterator]();!(t=(o=r.next()).done);t=!0){(0,o.value)()}}catch(t){e=!0,i=t}finally{try{!t&&r.return&&r.return()}finally{if(e)throw i}}this.sub&&(this.sub.unsubscribe(),this.sub=null)}},{key:"generateApolloOptions",value:function(t){var e=b(this.options,this.vueApolloSpecialKeys);return e.variables=t,e}},{key:"executeApollo",value:function(t){this.starting=!1}},{key:"nextResult",value:function(t){var e=t.error;e&&g(e)}},{key:"callHandlers",value:function(t){for(var e=!1,i=arguments.length,o=Array(i>1?i-1:0),r=1;r3&&void 0!==arguments[3])||arguments[3];(n(this,e),o.query)||(o={query:o});t.$data.$apolloData&&!t.$data.$apolloData.queries[i]&&t.$set(t.$data.$apolloData.queries,i,{loading:!1});var s=h(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,i,o,r));return s.type="query",s.vueApolloSpecialKeys=$,s._loading=!1,o.manual||(s.hasDataField=s.vm.$data.hasOwnProperty(i),s.hasDataField?Object.defineProperty(s.vm.$data.$apolloData.data,i,{get:function(){return s.vm.$data[i]},enumerable:!0,configurable:!0}):Object.defineProperty(s.vm.$data,i,{get:function(){return s.vm.$data.$apolloData.data[i]},enumerable:!0,configurable:!0})),s}return u(e,m),s(e,[{key:"stop",value:function(){l(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"stop",this).call(this),this.observer&&(this.observer.stopPolling(),this.observer=null)}},{key:"executeApollo",value:function(t){if(this.observer?this.observer.setOptions(this.generateApolloOptions(t)):(this.sub&&this.sub.unsubscribe(),this.observer=this.vm.$apollo.watchQuery(this.generateApolloOptions(t))),this.startQuerySubscription(),"no-cache"!==this.options.fetchPolicy){var i=this.maySetLoading();i.loading||this.nextResult(i)}l(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"executeApollo",this).call(this,t)}},{key:"startQuerySubscription",value:function(){this.sub&&!this.sub.closed||(this.sub=this.observer.subscribe({next:this.nextResult.bind(this),error:this.catchError.bind(this)}))}},{key:"maySetLoading",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],e=this.observer.currentResult();return(t||e.loading)&&(this.loading||this.applyLoadingModifier(1),this.loading=!0),e}},{key:"nextResult",value:function(t){l(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"nextResult",this).call(this,t);var i=t.data;t.loading||this.loadingDone();var o="function"==typeof this.options.result;void 0===i||(this.options.manual?o||console.error(this.key+" query must have a 'result' hook in manual mode"):"function"==typeof this.options.update?this.setData(this.options.update.call(this.vm,i)):void 0===i[this.key]&&Object.keys(i).length?console.error("Missing "+this.key+" attribute on result",i):this.setData(i[this.key])),o&&this.options.result.call(this.vm,t)}},{key:"setData",value:function(t){this.vm.$set(this.hasDataField?this.vm.$data:this.vm.$data.$apolloData.data,this.key,t)}},{key:"catchError",value:function(t){l(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"catchError",this).call(this,t),this.loadingDone(),this.nextResult(this.observer.currentResult()),this.resubscribeToQuery()}},{key:"resubscribeToQuery",value:function(){var t=this.observer.getLastError(),e=this.observer.getLastResult();this.observer.resetLastResults(),this.startQuerySubscription(),Object.assign(this.observer,{lastError:t,lastResult:e})}},{key:"watchLoading",value:function(){for(var t=arguments.length,e=Array(t),i=0;i0&&void 0!==arguments[0]?arguments[0]:null;if(!t||!t.client){if("object"===r(this.client))return this.client;if(this.client){if(this.provider.clients){var e=this.provider.clients[this.client];if(!e)throw new Error("[vue-apollo] Missing client '"+this.client+"' in 'apolloProvider'");return e}throw new Error("[vue-apollo] Missing 'clients' options in 'apolloProvider'")}return this.provider.defaultClient}var i=this.provider.clients[t.client];if(!i)throw new Error("[vue-apollo] Missing client '"+t.client+"' in 'apolloProvider'");return i}},{key:"watchQuery",value:function(t){var e=this,i=this.getClient(t).watchQuery(t),o=i.subscribe.bind(i);return i.subscribe=function(t){var i=o(t);return e._apolloSubscriptions.push(i),i},i}},{key:"mutate",value:function(t){return this.getClient(t).mutate(t)}},{key:"subscribe",value:function(t){var e=this;if(!this.vm.$isServer){var i=this.getClient(t).subscribe(t),o=i.subscribe.bind(i);return i.subscribe=function(t){var i=o(t);return e._apolloSubscriptions.push(i),i},i}}},{key:"addSmartQuery",value:function(t,e){var i=this,o=y(e,this.vm),r=this.vm.$options.apollo,n=this.provider.defaultOptions,s=void 0;if(r&&r.$query&&(s=r.$query),r&&r.$query||!n||!n.$query||(s=n.$query),s)for(var l in s)void 0===o[l]&&(o[l]=s[l]);var u=this.queries[t]=new k(this.vm,t,o,!1);if(this.vm.$isServer&&!1===o.prefetch||u.autostart(),!this.vm.$isServer){var h=o.subscribeToMore;h&&(Array.isArray(h)?h.forEach(function(e,o){i.addSmartSubscription(""+t+o,a({},e,{linkedQuery:u}))}):this.addSmartSubscription(t,a({},h,{linkedQuery:u})))}return u}},{key:"addSmartSubscription",value:function(t,e){if(!this.vm.$isServer){e=y(e,this.vm);var i=this.subscriptions[t]=new O(this.vm,t,e,!1);return i.autostart(),i}}},{key:"defineReactiveSetter",value:function(t,e,i){var o=this;this._watchers.push(this.vm.$watch(e,function(e){o[t]=e},{immediate:!0,deep:i}))}},{key:"destroy",value:function(){var t=!0,e=!1,i=void 0;try{for(var o,r=this._watchers[Symbol.iterator]();!(t=(o=r.next()).done);t=!0){(0,o.value)()}}catch(t){e=!0,i=t}finally{try{!t&&r.return&&r.return()}finally{if(e)throw i}}for(var n in this.queries)this.queries[n].destroy();for(var s in this.subscriptions)this.subscriptions[s].destroy();this._apolloSubscriptions.forEach(function(t){t.unsubscribe()}),this._apolloSubscriptions=null,this.vm=null}},{key:"provider",get:function(){return this.vm.$apolloProvider}},{key:"loading",get:function(){return 0!==this.vm.$data.$apolloData.loading}},{key:"data",get:function(){return this.vm.$data.$apolloData.data}},{key:"skipAllQueries",set:function(t){for(var e in this.queries)this.queries[e].skip=t}},{key:"skipAllSubscriptions",set:function(t){for(var e in this.subscriptions)this.subscriptions[e].skip=t}},{key:"skipAll",set:function(t){this.skipAllQueries=t,this.skipAllSubscriptions=t}}]),t}(),w=function(){function t(e){if(n(this,t),!e)throw new Error("Options argument required");this.clients=e.clients||{},this.clients.defaultClient=this.defaultClient=e.defaultClient,this.defaultOptions=e.defaultOptions,this.watchLoading=e.watchLoading,this.errorHandler=e.errorHandler,this.prefetchQueries=[]}return s(t,[{key:"provide",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"$apolloProvider";return console.warn(".provide() is deprecated. Use the 'apolloProvider' option instead with the provider object directly."),function(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}({},t,this)}}]),t}();var S={name:"ApolloQuery",provide:function(){return{getDollarApollo:this.getDollarApollo,getApolloQuery:this.getApolloQuery}},props:{query:{type:Object,required:!0},variables:{type:Object,default:void 0},fetchPolicy:{type:String,default:void 0},pollInterval:{type:Number,default:void 0},notifyOnNetworkStatusChange:{type:Boolean,default:void 0},context:{type:Object,default:void 0},skip:{type:Boolean,default:!1},debounce:{type:Number,default:0},throttle:{type:Number,default:0},clientId:{type:String,default:void 0},deep:{type:Boolean,default:void 0},tag:{type:String,default:"div"}},data:function(){return{result:{data:null,loading:!1,networkStatus:7,error:null},times:0}},watch:{fetchPolicy:function(t){this.$apollo.queries.query.setOptions({fetchPolicy:t})},pollInterval:function(t){this.$apollo.queries.query.setOptions({pollInterval:t})},notifyOnNetworkStatusChange:function(t){this.$apollo.queries.query.setOptions({notifyOnNetworkStatusChange:t})}},apollo:{$client:function(){return this.clientId},query:function(){return{query:function(){return this.query},variables:function(){return this.variables},fetchPolicy:this.fetchPolicy,pollInterval:this.pollInterval,debounce:this.debounce,throttle:this.throttle,notifyOnNetworkStatusChange:this.notifyOnNetworkStatusChange,context:function(){return this.context},skip:function(){return this.skip},deep:this.deep,manual:!0,result:function(t){var e=t,i=e.errors,o=e.loading,r=e.networkStatus,n=t.error;t=Object.assign({},t),i&&i.length&&((n=new Error("Apollo errors occured ("+i.length+")")).graphQLErrors=i);var s={};o?Object.assign(s,this.$_previousData,t.data):n?Object.assign(s,this.$apollo.queries.query.observer.getLastResult()||{},t.data):(s=t.data,this.$_previousData=t.data),this.result={data:function(t){return Object.keys(t).length>0}(s)?s:void 0,loading:o,error:n,networkStatus:r},this.times=++this.$_times,this.$emit("result",this.result)},error:function(t){this.result.loading=!1,this.result.error=t,this.$emit("error",t)}}}},created:function(){this.$_times=0},methods:{getDollarApollo:function(){return this.$apollo},getApolloQuery:function(){return this.$apollo.queries.query}},render:function(t){var e=this.$scopedSlots.default({result:this.result,times:this.times,query:this.$apollo.queries.query,isLoading:this.$apolloData.loading,gqlError:this.result&&this.result.error&&this.result.error.gqlError});return e=Array.isArray(e)?e.concat(this.$slots.default):[e].concat(this.$slots.default),this.tag?t(this.tag,e):e}},A=0,q={name:"ApolloSubscribeToMore",inject:["getDollarApollo","getApolloQuery"],props:{document:{type:Object,required:!0},variables:{type:Object,default:void 0},updateQuery:{type:Function,default:void 0}},watch:{document:"refresh",variables:"refresh"},created:function(){this.$_key="sub_component_"+A++},mounted:function(){this.refresh()},beforeDestroy:function(){this.destroy()},methods:{destroy:function(){this.$_sub&&this.$_sub.destroy()},refresh:function(){this.destroy(),this.$_sub=this.getDollarApollo().addSmartSubscription(this.$_key,{document:this.document,variables:this.variables,updateQuery:this.updateQuery,linkedQuery:this.getApolloQuery()})}},render:function(t){return null}},P={props:{mutation:{type:Object,required:!0},variables:{type:Object,default:void 0},optimisticResponse:{type:Object,default:void 0},update:{type:Function,default:void 0},refetchQueries:{type:Function,default:void 0},clientId:{type:String,default:void 0},tag:{type:String,default:"div"}},data:function(){return{loading:!1,error:null}},methods:{mutate:function(t){var e=this;this.loading=!0,this.error=null,this.$apollo.mutate(a({mutation:this.mutation,client:this.clientId,variables:this.variables,optimisticResponse:this.optimisticResponse,update:this.update,refetchQueries:this.refetchQueries},t)).then(function(t){e.$emit("done",t),e.loading=!1}).catch(function(t){g(t),e.error=t,e.$emit("error",t),e.loading=!1})}},render:function(t){var e=this.$scopedSlots.default({mutate:this.mutate,loading:this.loading,error:this.error,gqlError:this.error&&this.error.gqlError});return e=Array.isArray(e)?e.concat(this.$slots.default):[e].concat(this.$slots.default),this.tag?t(this.tag,e):e}};function j(t,e){return void 0!==t&&Object.prototype.hasOwnProperty.call(t,e)}function Q(){var t=this.$options,e=t.apolloProvider;if(e)this.$apolloProvider="function"==typeof e?e():e;else if(t.parent&&t.parent.$apolloProvider)this.$apolloProvider=t.parent.$apolloProvider;else if(t.provide){var i="function"==typeof t.provide?t.provide.call(this):t.provide;i.$apolloProvider&&(this.$apolloProvider=i.$apolloProvider)}}function D(){var t=this,e=this.$apolloProvider;if(!this._apolloLaunched&&e){this._apolloLaunched=!0;var i=this.$options.apollo;if(i){for(var o in i.$init||(i.$init=!0,e.defaultOptions&&(i=this.$options.apollo=Object.assign({},e.defaultOptions,i))),x(this.$apollo,"skipAll",i.$skipAll,i.$deep),x(this.$apollo,"skipAllQueries",i.$skipAllQueries,i.$deep),x(this.$apollo,"skipAllSubscriptions",i.$skipAllSubscriptions,i.$deep),x(this.$apollo,"client",i.$client,i.$deep),x(this.$apollo,"loadingKey",i.$loadingKey,i.$deep),x(this.$apollo,"error",i.$error,i.$deep),x(this.$apollo,"watchLoading",i.$watchLoading,i.$deep),Object.defineProperty(this,"$apolloData",{get:function(){return t.$data.$apolloData},enumerable:!0,configurable:!0}),i)if("$"!==o.charAt(0)){var r=i[o];this.$apollo.addSmartQuery(o,r)}if(i.subscribe&&d.Vue.util.warn("vue-apollo -> `subscribe` option is deprecated. Use the `$subscribe` option instead."),i.$subscribe)for(var n in i.$subscribe)this.$apollo.addSmartSubscription(n,i.$subscribe[n])}}}function x(t,e,i,o){void 0!==i&&("function"==typeof i?t.defineReactiveSetter(e,i,o):t[e]=i)}function E(t,e){t.mixin(a({},"1"===e?{init:Q}:{},"2"===e?{data:function(){return{$apolloData:{queries:{},loading:0,data:{}}}},beforeCreate:function(){Q.call(this),function(){var t=this,e=this.$options.apollo;if(e){var i=function(i){"$"!==i.charAt(0)&&(e[i].manual||j(t.$options.props,i)||j(t.$options.computed,i)||j(t.$options.methods,i)||Object.defineProperty(t,i,{get:function(){return t.$data.$apolloData.data[i]},enumerable:!0,configurable:!0}))};for(var o in e)i(o)}}.call(this)}}:{},{created:D,destroyed:function(){this.$_apollo&&(this.$_apollo.destroy(),this.$_apollo=null)}}))}var L=["$subscribe"];function M(t,e){if(!M.installed){M.installed=!0,d.Vue=t;var i=t.version.substr(0,t.version.indexOf(".")),o=t.config.optionMergeStrategies.methods;t.config.optionMergeStrategies.apollo=function(t,e,i){if(!t)return e;if(!e)return t;for(var r=Object.assign({},b(t,L),t.data),n=Object.assign({},b(e,L),e.data),s={},a=0;at?u():!0!==e&&(r=setTimeout(o?function(){r=void 0}:u,void 0===o?t-a:t))}}var i,o=Object.freeze({throttle:e,debounce:function(t,i,o){return void 0===o?e(t,i,!1):e(t,o,!1!==i)}}),r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},s=function(){function t(t,e){for(var i=0;i3&&void 0!==arguments[3])||arguments[3];n(this,t),this.type=null,this.vueApolloSpecialKeys=[],this.vm=e,this.key=i,this.initialOptions=o,this.options=Object.assign({},o),this._skip=!1,this._watchers=[],this._destroyed=!1,this.vm.$isServer&&(this.options.fetchPolicy="cache-first"),r&&this.autostart()}return s(t,[{key:"autostart",value:function(){"function"==typeof this.options.skip?this._skipWatcher=this.vm.$watch(this.options.skip.bind(this.vm),this.skipChanged.bind(this),{immediate:!0,deep:this.options.deep}):this.options.skip?this._skip=!0:this.start()}},{key:"skipChanged",value:function(t,e){t!==e&&(this.skip=t)}},{key:"refresh",value:function(){this._skip||(this.stop(),this.start())}},{key:"start",value:function(){var t=this;if(this.starting=!0,"function"==typeof this.initialOptions.query){var e=this.initialOptions.query.bind(this.vm);this.options.query=e(),this._watchers.push(this.vm.$watch(e,function(e){t.options.query=e,t.refresh()},{deep:this.options.deep}))}if("function"==typeof this.initialOptions.document){var i=this.initialOptions.document.bind(this.vm);this.options.document=i(),this._watchers.push(this.vm.$watch(i,function(e){t.options.document=e,t.refresh()},{deep:this.options.deep}))}if("function"==typeof this.initialOptions.context){var o=this.initialOptions.context.bind(this.vm);this.options.context=o(),this._watchers.push(this.vm.$watch(o,function(e){t.options.context=e,t.refresh()},{deep:this.options.deep}))}if("function"==typeof this.options.variables){var r=this.executeApollo.bind(this);r=this.options.throttle?f(r,this.options.throttle):r,r=this.options.debounce?v(r,this.options.debounce):r,this._watchers.push(this.vm.$watch(function(){return t.options.variables.call(t.vm)},r,{immediate:!0,deep:this.options.deep}))}else this.executeApollo(this.options.variables)}},{key:"stop",value:function(){var t=!0,e=!1,i=void 0;try{for(var o,r=this._watchers[Symbol.iterator]();!(t=(o=r.next()).done);t=!0){(0,o.value)()}}catch(t){e=!0,i=t}finally{try{!t&&r.return&&r.return()}finally{if(e)throw i}}this.sub&&(this.sub.unsubscribe(),this.sub=null)}},{key:"generateApolloOptions",value:function(t){var e=b(this.options,this.vueApolloSpecialKeys);return e.variables=t,e}},{key:"executeApollo",value:function(t){this.starting=!1}},{key:"nextResult",value:function(t){var e=t.error;e&&g(e)}},{key:"callHandlers",value:function(t){for(var e=!1,i=arguments.length,o=Array(i>1?i-1:0),r=1;r3&&void 0!==arguments[3])||arguments[3];(n(this,e),o.query)||(o={query:o});t.$data.$apolloData&&!t.$data.$apolloData.queries[i]&&t.$set(t.$data.$apolloData.queries,i,{loading:!1});var s=h(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,i,o,r));return s.type="query",s.vueApolloSpecialKeys=$,s._loading=!1,o.manual||(s.hasDataField=s.vm.$data.hasOwnProperty(i),s.hasDataField?Object.defineProperty(s.vm.$data.$apolloData.data,i,{get:function(){return s.vm.$data[i]},enumerable:!0,configurable:!0}):Object.defineProperty(s.vm.$data,i,{get:function(){return s.vm.$data.$apolloData.data[i]},enumerable:!0,configurable:!0})),s}return u(e,m),s(e,[{key:"stop",value:function(){l(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"stop",this).call(this),this.observer&&(this.observer.stopPolling(),this.observer=null)}},{key:"executeApollo",value:function(t){if(this.observer?this.observer.setOptions(this.generateApolloOptions(t)):(this.sub&&this.sub.unsubscribe(),this.observer=this.vm.$apollo.watchQuery(this.generateApolloOptions(t))),this.startQuerySubscription(),"no-cache"!==this.options.fetchPolicy){var i=this.maySetLoading();i.loading||this.nextResult(i)}l(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"executeApollo",this).call(this,t)}},{key:"startQuerySubscription",value:function(){this.sub&&!this.sub.closed||(this.sub=this.observer.subscribe({next:this.nextResult.bind(this),error:this.catchError.bind(this)}))}},{key:"maySetLoading",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],e=this.observer.currentResult();return(t||e.loading)&&(this.loading||this.applyLoadingModifier(1),this.loading=!0),e}},{key:"nextResult",value:function(t){l(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"nextResult",this).call(this,t);var i=t.data;t.loading||this.loadingDone();var o="function"==typeof this.options.result;void 0===i||(this.options.manual?o||console.error(this.key+" query must have a 'result' hook in manual mode"):"function"==typeof this.options.update?this.setData(this.options.update.call(this.vm,i)):void 0===i[this.key]&&Object.keys(i).length?console.error("Missing "+this.key+" attribute on result",i):this.setData(i[this.key])),o&&this.options.result.call(this.vm,t)}},{key:"setData",value:function(t){this.vm.$set(this.hasDataField?this.vm.$data:this.vm.$data.$apolloData.data,this.key,t)}},{key:"catchError",value:function(t){l(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"catchError",this).call(this,t),this.loadingDone(),this.nextResult(this.observer.currentResult()),this.resubscribeToQuery()}},{key:"resubscribeToQuery",value:function(){var t=this.observer.getLastError(),e=this.observer.getLastResult();this.observer.resetLastResults(),this.startQuerySubscription(),Object.assign(this.observer,{lastError:t,lastResult:e})}},{key:"watchLoading",value:function(){for(var t=arguments.length,e=Array(t),i=0;i0&&void 0!==arguments[0]?arguments[0]:null;if(!t||!t.client){if("object"===r(this.client))return this.client;if(this.client){if(this.provider.clients){var e=this.provider.clients[this.client];if(!e)throw new Error("[vue-apollo] Missing client '"+this.client+"' in 'apolloProvider'");return e}throw new Error("[vue-apollo] Missing 'clients' options in 'apolloProvider'")}return this.provider.defaultClient}var i=this.provider.clients[t.client];if(!i)throw new Error("[vue-apollo] Missing client '"+t.client+"' in 'apolloProvider'");return i}},{key:"watchQuery",value:function(t){var e=this,i=this.getClient(t).watchQuery(t),o=i.subscribe.bind(i);return i.subscribe=function(t){var i=o(t);return e._apolloSubscriptions.push(i),i},i}},{key:"mutate",value:function(t){return this.getClient(t).mutate(t)}},{key:"subscribe",value:function(t){var e=this;if(!this.vm.$isServer){var i=this.getClient(t).subscribe(t),o=i.subscribe.bind(i);return i.subscribe=function(t){var i=o(t);return e._apolloSubscriptions.push(i),i},i}}},{key:"addSmartQuery",value:function(t,e){var i=this,o=y(e,this.vm),r=this.vm.$options.apollo,n=this.provider.defaultOptions,s=void 0;if(r&&r.$query&&(s=r.$query),r&&r.$query||!n||!n.$query||(s=n.$query),s)for(var l in s)void 0===o[l]&&(o[l]=s[l]);var u=this.queries[t]=new k(this.vm,t,o,!1);if(this.vm.$isServer&&!1===o.prefetch||u.autostart(),!this.vm.$isServer){var h=o.subscribeToMore;h&&(Array.isArray(h)?h.forEach(function(e,o){i.addSmartSubscription(""+t+o,a({},e,{linkedQuery:u}))}):this.addSmartSubscription(t,a({},h,{linkedQuery:u})))}return u}},{key:"addSmartSubscription",value:function(t,e){if(!this.vm.$isServer){e=y(e,this.vm);var i=this.subscriptions[t]=new O(this.vm,t,e,!1);return i.autostart(),i}}},{key:"defineReactiveSetter",value:function(t,e,i){var o=this;this._watchers.push(this.vm.$watch(e,function(e){o[t]=e},{immediate:!0,deep:i}))}},{key:"destroy",value:function(){var t=!0,e=!1,i=void 0;try{for(var o,r=this._watchers[Symbol.iterator]();!(t=(o=r.next()).done);t=!0){(0,o.value)()}}catch(t){e=!0,i=t}finally{try{!t&&r.return&&r.return()}finally{if(e)throw i}}for(var n in this.queries)this.queries[n].destroy();for(var s in this.subscriptions)this.subscriptions[s].destroy();this._apolloSubscriptions.forEach(function(t){t.unsubscribe()}),this._apolloSubscriptions=null,this.vm=null}},{key:"provider",get:function(){return this.vm.$apolloProvider}},{key:"loading",get:function(){return 0!==this.vm.$data.$apolloData.loading}},{key:"data",get:function(){return this.vm.$data.$apolloData.data}},{key:"skipAllQueries",set:function(t){for(var e in this.queries)this.queries[e].skip=t}},{key:"skipAllSubscriptions",set:function(t){for(var e in this.subscriptions)this.subscriptions[e].skip=t}},{key:"skipAll",set:function(t){this.skipAllQueries=t,this.skipAllSubscriptions=t}}]),t}(),w=function(){function t(e){if(n(this,t),!e)throw new Error("Options argument required");this.clients=e.clients||{},this.clients.defaultClient=this.defaultClient=e.defaultClient,this.defaultOptions=e.defaultOptions,this.watchLoading=e.watchLoading,this.errorHandler=e.errorHandler,this.prefetchQueries=[]}return s(t,[{key:"provide",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"$apolloProvider";return console.warn(".provide() is deprecated. Use the 'apolloProvider' option instead with the provider object directly."),function(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}({},t,this)}}]),t}();var S={name:"ApolloQuery",provide:function(){return{getDollarApollo:this.getDollarApollo,getApolloQuery:this.getApolloQuery}},props:{query:{type:Object,required:!0},variables:{type:Object,default:void 0},fetchPolicy:{type:String,default:void 0},pollInterval:{type:Number,default:void 0},notifyOnNetworkStatusChange:{type:Boolean,default:void 0},context:{type:Object,default:void 0},skip:{type:Boolean,default:!1},debounce:{type:Number,default:0},throttle:{type:Number,default:0},clientId:{type:String,default:void 0},deep:{type:Boolean,default:void 0},tag:{type:String,default:"div"}},data:function(){return{result:{data:null,loading:!1,networkStatus:7,error:null},times:0}},watch:{fetchPolicy:function(t){this.$apollo.queries.query.setOptions({fetchPolicy:t})},pollInterval:function(t){this.$apollo.queries.query.setOptions({pollInterval:t})},notifyOnNetworkStatusChange:function(t){this.$apollo.queries.query.setOptions({notifyOnNetworkStatusChange:t})}},apollo:{$client:function(){return this.clientId},query:function(){return{query:function(){return this.query},variables:function(){return this.variables},fetchPolicy:this.fetchPolicy,pollInterval:this.pollInterval,debounce:this.debounce,throttle:this.throttle,notifyOnNetworkStatusChange:this.notifyOnNetworkStatusChange,context:function(){return this.context},skip:function(){return this.skip},deep:this.deep,manual:!0,result:function(t){var e=t,i=e.errors,o=e.loading,r=e.networkStatus,n=t.error;t=Object.assign({},t),i&&i.length&&((n=new Error("Apollo errors occured ("+i.length+")")).graphQLErrors=i);var s={};o?Object.assign(s,this.$_previousData,t.data):n?Object.assign(s,this.$apollo.queries.query.observer.getLastResult()||{},t.data):(s=t.data,this.$_previousData=t.data),this.result={data:function(t){return Object.keys(t).length>0}(s)?s:void 0,loading:o,error:n,networkStatus:r},this.times=++this.$_times,this.$emit("result",this.result)},error:function(t){this.result.loading=!1,this.result.error=t,this.$emit("error",t)}}}},created:function(){this.$_times=0},methods:{getDollarApollo:function(){return this.$apollo},getApolloQuery:function(){return this.$apollo.queries.query}},render:function(t){var e=this.$scopedSlots.default({result:this.result,times:this.times,query:this.$apollo.queries.query,isLoading:this.$apolloData.loading,gqlError:this.result&&this.result.error&&this.result.error.gqlError});return e=Array.isArray(e)?e.concat(this.$slots.default):[e].concat(this.$slots.default),this.tag?t(this.tag,e):e}},A=0,q={name:"ApolloSubscribeToMore",inject:["getDollarApollo","getApolloQuery"],props:{document:{type:Object,required:!0},variables:{type:Object,default:void 0},updateQuery:{type:Function,default:void 0}},watch:{document:"refresh",variables:"refresh"},created:function(){this.$_key="sub_component_"+A++},mounted:function(){this.refresh()},beforeDestroy:function(){this.destroy()},methods:{destroy:function(){this.$_sub&&this.$_sub.destroy()},refresh:function(){this.destroy(),this.$_sub=this.getDollarApollo().addSmartSubscription(this.$_key,{document:this.document,variables:this.variables,updateQuery:this.updateQuery,linkedQuery:this.getApolloQuery()})}},render:function(t){return null}},P={props:{mutation:{type:Object,required:!0},variables:{type:Object,default:void 0},optimisticResponse:{type:Object,default:void 0},update:{type:Function,default:void 0},refetchQueries:{type:Function,default:void 0},clientId:{type:String,default:void 0},tag:{type:String,default:"div"}},data:function(){return{loading:!1,error:null}},methods:{mutate:function(t){var e=this;this.loading=!0,this.error=null,this.$apollo.mutate(a({mutation:this.mutation,client:this.clientId,variables:this.variables,optimisticResponse:this.optimisticResponse,update:this.update,refetchQueries:this.refetchQueries},t)).then(function(t){e.$emit("done",t),e.loading=!1}).catch(function(t){g(t),e.error=t,e.$emit("error",t),e.loading=!1})}},render:function(t){var e=this.$scopedSlots.default({mutate:this.mutate,loading:this.loading,error:this.error,gqlError:this.error&&this.error.gqlError});return e=Array.isArray(e)?e.concat(this.$slots.default):[e].concat(this.$slots.default),this.tag?t(this.tag,e):e}};function j(t,e){return void 0!==t&&Object.prototype.hasOwnProperty.call(t,e)}function Q(){var t=this.$options,e=t.apolloProvider;if(e)this.$apolloProvider="function"==typeof e?e():e;else if(t.parent&&t.parent.$apolloProvider)this.$apolloProvider=t.parent.$apolloProvider;else if(t.provide){var i="function"==typeof t.provide?t.provide.call(this):t.provide;i.$apolloProvider&&(this.$apolloProvider=i.$apolloProvider)}}function D(){var t=this,e=this.$apolloProvider;if(!this._apolloLaunched&&e){this._apolloLaunched=!0;var i=this.$options.apollo;if(i){for(var o in i.$init||(i.$init=!0,e.defaultOptions&&(i=this.$options.apollo=Object.assign({},e.defaultOptions,i))),x(this.$apollo,"skipAll",i.$skipAll,i.$deep),x(this.$apollo,"skipAllQueries",i.$skipAllQueries,i.$deep),x(this.$apollo,"skipAllSubscriptions",i.$skipAllSubscriptions,i.$deep),x(this.$apollo,"client",i.$client,i.$deep),x(this.$apollo,"loadingKey",i.$loadingKey,i.$deep),x(this.$apollo,"error",i.$error,i.$deep),x(this.$apollo,"watchLoading",i.$watchLoading,i.$deep),Object.defineProperty(this,"$apolloData",{get:function(){return t.$data.$apolloData},enumerable:!0,configurable:!0}),i)if("$"!==o.charAt(0)){var r=i[o];this.$apollo.addSmartQuery(o,r)}if(i.subscribe&&d.Vue.util.warn("vue-apollo -> `subscribe` option is deprecated. Use the `$subscribe` option instead."),i.$subscribe)for(var n in i.$subscribe)this.$apollo.addSmartSubscription(n,i.$subscribe[n])}}}function x(t,e,i,o){void 0!==i&&("function"==typeof i?t.defineReactiveSetter(e,i,o):t[e]=i)}function E(t,e){t.mixin(a({},"1"===e?{init:Q}:{},"2"===e?{data:function(){return{$apolloData:{queries:{},loading:0,data:{}}}},beforeCreate:function(){Q.call(this),function(){var t=this,e=this.$options.apollo;if(e){var i=function(i){"$"!==i.charAt(0)&&(e[i].manual||j(t.$options.props,i)||j(t.$options.computed,i)||j(t.$options.methods,i)||Object.defineProperty(t,i,{get:function(){return t.$data.$apolloData.data[i]},enumerable:!0,configurable:!0}))};for(var o in e)i(o)}}.call(this)}}:{},{created:D,destroyed:function(){this.$_apollo&&(this.$_apollo.destroy(),this.$_apollo=null)}}))}var L=["$subscribe"];function M(t,e){if(!M.installed){M.installed=!0,d.Vue=t;var i=t.version.substr(0,t.version.indexOf(".")),o=t.config.optionMergeStrategies.methods;t.config.optionMergeStrategies.apollo=function(t,e,i){if(!t)return e;if(!e)return t;for(var r=Object.assign({},b(t,L),t.data),n=Object.assign({},b(e,L),e.data),s={},a=0;a