diff --git a/dist/vue-apollo.esm.js b/dist/vue-apollo.esm.js index 1809f93..fee5d19 100644 --- a/dist/vue-apollo.esm.js +++ b/dist/vue-apollo.esm.js @@ -3921,7 +3921,12 @@ var launch = function launch() { var _loop = function _loop(key) { if (key.charAt(0) !== '$') { - if (!_this.hasOwnProperty(key) && !_this.$props.hasOwnProperty(key) && !_this.$data.hasOwnProperty(key)) { + var propHasKeyProperty = false; + if (typeof _this.$props !== 'undefined') { + propHasKeyProperty = _this.$props.hasOwnProperty(key); + } + + if (!_this.hasOwnProperty(key) && !propHasKeyProperty && !_this.$data.hasOwnProperty(key)) { Object.defineProperty(_this, key, { get: function get$$1() { return _this.$data.$apolloData.data[key]; diff --git a/dist/vue-apollo.min.js b/dist/vue-apollo.min.js index af7d252..e7e8940 100644 --- a/dist/vue-apollo.min.js +++ b/dist/vue-apollo.min.js @@ -1 +1 @@ -var VueApollo=function(t){"use strict";var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},r=200,o="__lodash_hash_undefined__",i=1/0,n=9007199254740991,s="[object Arguments]",a="[object Function]",u="[object GeneratorFunction]",l="[object Symbol]",c=/^\[object .+?Constructor\]$/,h=/^(?:0|[1-9]\d*)$/,p="object"==typeof e&&e&&e.Object===Object&&e,f="object"==typeof self&&self&&self.Object===Object&&self,v=p||f||Function("return this")();function d(t,e){return!!(t?t.length:0)&&function(t,e,r){if(e!=e)return function(t,e,r,o){var i=t.length,n=r+(o?1:-1);for(;o?n--:++n-1}function y(t,e,r){for(var o=-1,i=t?t.length:0;++o-1},K.prototype.set=function(t,e){var r=this.__data__,o=H(r,t);return o<0?r.push([t,e]):r[o][1]=e,this},I.prototype.clear=function(){this.__data__={hash:new V,map:new(R||K),string:new V}},I.prototype.delete=function(t){return U(this,t).delete(t)},I.prototype.get=function(t){return U(this,t).get(t)},I.prototype.has=function(t){return U(this,t).has(t)},I.prototype.set=function(t,e){return U(this,t).set(t,e),this},F.prototype.add=F.prototype.push=function(t){return this.__data__.set(t,o),this},F.prototype.has=function(t){return this.__data__.has(t)};var X=C?$(C,Object):ht,Y=C?function(t){for(var e=[];t;)g(e,X(t)),t=E(t);return e}:ht;function Z(t){return nt(t)||rt(t)||!!(T&&t&&t[T])}function tt(t,e){return!!(e=null==e?n:e)&&("number"==typeof t||h.test(t))&&t>-1&&t%1==0&&t-1&&t%1==0&&t<=n}(t.length)&&!at(t)}function at(t){var e=ut(t)?x.call(t):"";return e==a||e==u}function ut(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function lt(t){return!!t&&"object"==typeof t}function ct(t){return st(t)?W(t,!0):J(t)}function ht(){return[]}var pt=(ot=function(t,e){return null==t?{}:(e=b(function t(e,r,o,i,n){var s=-1,a=e.length;for(o||(o=Z),n||(n=[]);++s0&&o(u)?r>1?t(u,r-1,o,i,n):g(n,u):i||(n[n.length]=u)}return n}(e,1),et),function(t,e){return function(t,e,r){for(var o=-1,i=e.length,n={};++o=r&&(a=_,u=!1,e=new F(e));t:for(;++s=e||r<0||h&&t-l>=n}function d(){var t=At();if(v(t))return y(t);a=setTimeout(d,function(t){var r=e-(t-u);return h?jt(r,n-(t-l)):r}(t))}function y(t){return a=void 0,p&&o?f(t):(o=i=void 0,s)}function b(){var t=At(),r=v(t);if(o=arguments,i=this,u=t,r){if(void 0===a)return function(t){return l=t,a=setTimeout(d,e),c?f(t):s}(u);if(h)return a=setTimeout(d,e),f(u)}return void 0===a&&(a=setTimeout(d,e)),s}return e=qt(e)||0,xt(r)&&(c=!!r.leading,n=(h="maxWait"in r)?St(qt(r.maxWait)||0,e):n,p="trailing"in r?!!r.trailing:p),b.cancel=function(){void 0!==a&&clearTimeout(a),l=0,o=u=i=a=void 0},b.flush=function(){return void 0===a?s:y(At())},b}function xt(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function qt(t){if("number"==typeof t)return t;if(function(t){return"symbol"==typeof t||function(t){return!!t&&"object"==typeof t}(t)&&Ot.call(t)==dt}(t))return vt;if(xt(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=xt(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(yt,"");var r=gt.test(t);return r||mt.test(t)?_t(t.slice(2),r?2:8):bt.test(t)?vt:+t}var Qt=function(t,e,r){var o=!0,i=!0;if("function"!=typeof t)throw new TypeError(ft);return xt(r)&&(o="leading"in r?!!r.leading:o,i="trailing"in r?!!r.trailing:i),Pt(t,e,{leading:o,maxWait:e,trailing:i})},Et="Expected a function",Lt=NaN,Dt="[object Symbol]",Tt=/^\s+|\s+$/g,Ct=/^[-+]0x[0-9a-f]+$/i,Mt=/^0b[01]+$/i,Rt=/^0o[0-7]+$/i,Nt=parseInt,Vt="object"==typeof e&&e&&e.Object===Object&&e,Kt="object"==typeof self&&self&&self.Object===Object&&self,It=Vt||Kt||Function("return this")(),Ft=Object.prototype.toString,Wt=Math.max,Ht=Math.min,Gt=function(){return It.Date.now()};function Jt(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function Bt(t){if("number"==typeof t)return t;if(function(t){return"symbol"==typeof t||function(t){return!!t&&"object"==typeof t}(t)&&Ft.call(t)==Dt}(t))return Lt;if(Jt(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=Jt(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(Tt,"");var r=Mt.test(t);return r||Rt.test(t)?Nt(t.slice(2),r?2:8):Ct.test(t)?Lt:+t}var Ut=function(t,e,r){var o,i,n,s,a,u,l=0,c=!1,h=!1,p=!0;if("function"!=typeof t)throw new TypeError(Et);function f(e){var r=o,n=i;return o=i=void 0,l=e,s=t.apply(n,r)}function v(t){var r=t-u;return void 0===u||r>=e||r<0||h&&t-l>=n}function d(){var t=Gt();if(v(t))return y(t);a=setTimeout(d,function(t){var r=e-(t-u);return h?Ht(r,n-(t-l)):r}(t))}function y(t){return a=void 0,p&&o?f(t):(o=i=void 0,s)}function b(){var t=Gt(),r=v(t);if(o=arguments,i=this,u=t,r){if(void 0===a)return function(t){return l=t,a=setTimeout(d,e),c?f(t):s}(u);if(h)return a=setTimeout(d,e),f(u)}return void 0===a&&(a=setTimeout(d,e)),s}return e=Bt(e)||0,Jt(r)&&(c=!!r.leading,n=(h="maxWait"in r)?Wt(Bt(r.maxWait)||0,e):n,p="trailing"in r?!!r.trailing:p),b.cancel=function(){void 0!==a&&clearTimeout(a),l=0,o=u=i=a=void 0},b.flush=function(){return void 0===a?s:y(Gt())},b},zt={};function Xt(t){return function(e,r){return"number"==typeof r?t(e,r):t(e,r.wait,r)}}var Yt=Xt(Qt),Zt=Xt(Ut);function te(t,e){for(;"function"==typeof t;)t=t.call(e);return t}var ee="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},re=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},oe=function(){function t(t,e){for(var r=0;r3&&void 0!==arguments[3])||arguments[3];if(re(this,t),this.type=null,this.vueApolloSpecialKeys=[],this.vm=e,this.key=r,this.options=Object.assign({},o),this._skip=!1,this._watchers=[],this._destroyed=!1,"function"==typeof this.options.query){var s=this.options.query.bind(this.vm);this.options.query=s(),this._watchers.push(this.vm.$watch(s,function(t){i.options.query=t,i.refresh()}))}if("function"==typeof this.options.document){var a=this.options.document.bind(this.vm);this.options.document=a(),this._watchers.push(this.vm.$watch(a,function(t){i.options.document=t,i.refresh()}))}if("function"==typeof this.options.context){var u=this.options.context.bind(this.vm);this.options.context=u(),this._watchers.push(this.vm.$watch(u,function(t){i.options.context=t,i.refresh()}))}this.vm.$isServer&&(this.options.fetchPolicy="cache-first"),n&&this.autostart()}return oe(t,[{key:"autostart",value:function(){"function"==typeof this.options.skip?this._watchers.push(this.vm.$watch(this.options.skip.bind(this.vm),this.skipChanged.bind(this),{immediate:!0})):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.options.variables){var e=this.executeApollo.bind(this);e=this.options.throttle?Yt(e,this.options.throttle):e,e=this.options.debounce?Zt(e,this.options.debounce):e,this.unwatchVariables=this.vm.$watch(function(){return t.options.variables.call(t.vm)},e,{immediate:!0})}else this.executeApollo(this.options.variables)}},{key:"stop",value:function(){this.unwatchVariables&&(this.unwatchVariables(),this.unwatchVariables=null),this.sub&&(this.sub.unsubscribe(),this.sub=null)}},{key:"generateApolloOptions",value:function(t){var e=pt(this.options,this.vueApolloSpecialKeys);return e.variables=t,e}},{key:"executeApollo",value:function(t){this.starting=!1}},{key:"nextResult",value:function(){throw new Error("Not implemented")}},{key:"errorHandler",value:function(){for(var t,e,r,o=arguments.length,i=Array(o),n=0;n3&&void 0!==arguments[3])||arguments[3];(re(this,e),o.query)||(o={query:o});t.$data.$apolloData&&!t.$data.$apolloData.queries[r]&&t.$set(t.$data.$apolloData.queries,r,{loading:!1});var n=ae(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,r,o,i));return n.type="query",n.vueApolloSpecialKeys=ce,n._loading=!1,n}return se(e,le),oe(e,[{key:"stop",value:function(){ne(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"stop",this).call(this),this.observer&&(this.observer.stopPolling(),this.observer=null)}},{key:"executeApollo",value:function(t){this.observer?this.observer.setOptions(this.generateApolloOptions(t)):(this.sub&&this.sub.unsubscribe(),this.observer=this.vm.$apollo.watchQuery(this.generateApolloOptions(t)),this.sub=this.observer.subscribe({next:this.nextResult.bind(this),error:this.catchError.bind(this)}));var r=this.maySetLoading();r.loading||this.nextResult(r),ne(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"executeApollo",this).call(this,t)}},{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){var e=t.data;t.loading||this.loadingDone();var r="function"==typeof this.options.result;void 0===e||(this.options.manual?r||console.error(this.key+" query must have a 'result' hook in manual mode"):"function"==typeof this.options.update?this.vm.$set(this.vm.$data.$apolloData.data,this.key,this.options.update.call(this.vm,e)):void 0===e[this.key]?console.error("Missing "+this.key+" attribute on result",e):this.vm.$set(this.vm.$data.$apolloData.data,this.key,e[this.key])),r&&this.options.result.call(this.vm,t)}},{key:"catchError",value:function(t){ne(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"catchError",this).call(this,t),this.loadingDone()}},{key:"watchLoading",value:function(){for(var t,e,r,o=arguments.length,i=Array(o),n=0;n0&&void 0!==arguments[0]?arguments[0]:null;if(!t||!t.client){if("object"===ee(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 r=this.provider.clients[t.client];if(!r)throw new Error("[vue-apollo] Missing client '"+t.client+"' in 'apolloProvider'");return r}},{key:"watchQuery",value:function(t){var e=this,r=this.getClient(t).watchQuery(t),o=r.subscribe.bind(r);return r.subscribe=function(t){var r=o(t);return e._apolloSubscriptions.push(r),r},r}},{key:"mutate",value:function(t){return this.getClient(t).mutate(t)}},{key:"subscribe",value:function(t){var e=this;if(!this.vm.$isServer){var r=this.getClient(t).subscribe(t),o=r.subscribe.bind(r);return r.subscribe=function(t){var r=o(t);return e._apolloSubscriptions.push(r),r},r}}},{key:"addSmartQuery",value:function(t,e){var r=this;e=te(e,this.vm);var o=this.queries[t]=new he(this.vm,t,e,!1);if(o.autostart(),!this.vm.$isServer){var i=e.subscribeToMore;i&&(Array.isArray(i)?i.forEach(function(e,i){r.addSmartSubscription(""+t+i,ie({},e,{linkedQuery:o}))}):this.addSmartSubscription(t,ie({},i,{linkedQuery:o})))}return o}},{key:"addSmartSubscription",value:function(t,e){if(!this.vm.$isServer){e=te(e,this.vm);var r=this.subscriptions[t]=new pe(this.vm,t,e,!1);return r.autostart(),r}}},{key:"defineReactiveSetter",value:function(t,e){var r=this;this._watchers.push(this.vm.$watch(e,function(e){r[t]=e},{immediate:!0}))}},{key:"destroy",value:function(){var t=!0,e=!1,r=void 0;try{for(var o,i=this._watchers[Symbol.iterator]();!(t=(o=i.next()).done);t=!0){(0,o.value)()}}catch(t){e=!0,r=t}finally{try{!t&&i.return&&i.return()}finally{if(e)throw r}}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 this.vm.$data.$apolloData&&0!==this.vm.$data.$apolloData.loading}},{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}(),ve=function(){function t(e){if(re(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 oe(t,[{key:"provide",value:function(){return function(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}({},arguments.length>0&&void 0!==arguments[0]?arguments[0]:"$apolloProvider",this)}},{key:"addQueryToPrefetch",value:function(t,e){this.prefetchQueries.push({queryOptions:t,client:e})}},{key:"prefetchComponent",value:function(t,e){var r;r=t;var o=(t=zt.Vue.util.mergeOptions({},r)).apollo;if(o){var i=o.$client;for(var n in o){var s=o[n];"$"===n.charAt(0)||s.query&&(void 0!==s.ssr&&!s.ssr||void 0===s.prefetch||!s.prefetch)||this.addQueryToPrefetch(s,s.client||i)}}}},{key:"prefetchComponents",value:function(t){var e=!0,r=!1,o=void 0;try{for(var i,n=t[Symbol.iterator]();!(e=(i=n.next()).done);e=!0){var s=i.value;this.prefetchComponent(s)}}catch(t){r=!0,o=t}finally{try{!e&&n.return&&n.return()}finally{if(r)throw o}}}},{key:"prefetchAll",value:function(t,e,r){var o=this;r||!e||Array.isArray(e)||(r=e,e=void 0);var i=Object.assign({},{includeGlobal:!0},r);return e&&this.prefetchComponents(e),i.includeGlobal&&this.prefetchComponents(de.filter(function(e){e.component;var r=e.contextCallback,o=!0;return"function"==typeof r&&(o=!!r(t)),o}).map(function(t){return t.component}),t),Promise.all(this.prefetchQueries.map(function(e){return o.prefetchQuery(e.queryOptions,t,e.client)}))}},{key:"prefetchQuery",value:function(t,e,r){var o=void 0;if(r){if("string"==typeof r&&!(r=this.clients[r]))throw new Error("[vue-apollo] Missing client '"+r+"' in 'apolloProvider'")}else r=this.defaultClient;if(t.query){var i=t.prefetch,n=void 0===i?"undefined":ee(i);if("undefined"!==n){var s=void 0;if(!(s="function"===n?i(e):i))return Promise.resolve();if("boolean"===n){var a=t.variables;o=void 0!==a?"function"==typeof a?a.call(e):a:void 0}else o=s}}else t={query:t};return"function"==typeof t.query&&(t.query=t.query(e)),new Promise(function(e,i){var n=pt(t,[].concat(ue(ce),["fetchPolicy"]));n.variables=o,n.fetchPolicy="network-only",r.query(n).then(e,i)})}},{key:"getStates",value:function(t){var e=Object.assign({},{exportNamespace:""},t),r={};for(var o in this.clients){var i=this.clients[o].cache.extract();r[""+e.exportNamespace+o]=i}return r}},{key:"exportStates",value:function(t){var e=Object.assign({},{globalName:"__APOLLO_STATE__",attachTo:"window"},t),r=this.getStates(e);return e.attachTo+"."+e.globalName+" = "+JSON.stringify(r)+";"}}]),t}(),de=[];function ye(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return de.push({component:t,contextCallback:e}),t}"undefined"!=typeof window?window.vueApolloWillPrefetch=ye:"undefined"!=typeof global&&(global.vueApolloWillPrefetch=ye);var be={name:"ApolloQuery",provide:function(){return{getDollarApollo:this.getDollarApollo,getApolloQuery:this.getApolloQuery}},props:{query:{type:Object,required:!0},variables:{type:Object,default:null},fetchPolicy:{type:String,default:"cache-first"},pollInterval:{type:Number,default:0},notifyOnNetworkStatusChange:{type:Boolean,default:!1},context:{type:Object,default:null},skip:{type:Boolean,default:!1},clientId:{type:String,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,notifyOnNetworkStatusChange:this.notifyOnNetworkStatusChange,context:function(){return this.context},skip:function(){return this.skip},manual:!0,result:function(t){var e=t,r=e.errors,o=e.loading,i=e.networkStatus,n=t.error;t=Object.assign({},t),r&&r.length&&((n=new Error("Apollo errors occured ("+r.length+")")).graphQLErrors=r);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:i,times:++this.$_times},this.$emit("result",this.result)},error:function(t){this.result.loading=!1,this.result.error=t,console.log(this.$apollo.queries.query.observer.currentResult()),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,query:this.$apollo.queries.query});return e=Array.isArray(e)?e.concat(this.$slots.default):[e].concat(this.$slots.default),t(this.tag,e)}},ge=0,me={name:"ApolloSubscribeToMore",inject:["getDollarApollo","getApolloQuery"],props:{document:{type:Object,required:!0},variables:{type:Object,default:null},updateQuery:{type:Function,default:null}},watch:{document:"refresh",variables:"refresh"},created:function(){this.$_key="sub_component_"+ge++},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}},_e={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},tag:{type:String,default:"div"}},data:function(){return{loading:!1,error:null}},methods:{mutate:function(t){var e,r=this;return(e=regeneratorRuntime.mark(function e(){var o;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return r.loading=!0,r.error=null,e.prev=2,e.next=5,r.$apollo.mutate(ie({mutation:r.mutation,variables:r.variables,optimisticResponse:r.optimisticResponse,update:r.update,refetchQueries:r.refetchQueries},t));case 5:o=e.sent,r.$emit("done",o),e.next=13;break;case 9:e.prev=9,e.t0=e.catch(2),r.error=e.t0,r.$emit("error",e.t0);case 13:r.loading=!1;case 14:case"end":return e.stop()}},e,r,[[2,9]])}),function(){var t=e.apply(this,arguments);return new Promise(function(e,r){return function o(i,n){try{var s=t[i](n),a=s.value}catch(t){return void r(t)}if(!s.done)return Promise.resolve(a).then(function(t){o("next",t)},function(t){o("throw",t)});e(a)}("next")})})()}},render:function(t){var e=this.$scopedSlots.default({mutate:this.mutate,loading:this.loading,error:this.error});return e=Array.isArray(e)?e.concat(this.$slots.default):[e].concat(this.$slots.default),t(this.tag,e)}},$e=["$subscribe"],ke=function(){var t=this,e=this.$apolloProvider;if(!this._apolloLaunched&&e){this._apolloLaunched=!0;var r=this.$options.apollo;if(r){r.$init||(r.$init=!0,e.defaultOptions&&(r=this.$options.apollo=Object.assign({},e.defaultOptions,r))),we(this.$apollo,"skipAll",r.$skipAll),we(this.$apollo,"skipAllQueries",r.$skipAllQueries),we(this.$apollo,"skipAllSubscriptions",r.$skipAllSubscriptions),we(this.$apollo,"client",r.$client),we(this.$apollo,"loadingKey",r.$loadingKey),we(this.$apollo,"error",r.$error),we(this.$apollo,"watchLoading",r.$watchLoading);var o=function(e){"$"!==e.charAt(0)&&(t.hasOwnProperty(e)||t.$props.hasOwnProperty(e)||t.$data.hasOwnProperty(e)||Object.defineProperty(t,e,{get:function(){return t.$data.$apolloData.data[e]},enumerable:!0,configurable:!0}),t.$apollo.addSmartQuery(e,r[e]))};for(var i in r)o(i);if(r.subscribe&&zt.Vue.util.warn("vue-apollo -> `subscribe` option is deprecated. Use the `$subscribe` option instead."),r.$subscribe)for(var i in r.$subscribe)this.$apollo.addSmartSubscription(i,r.$subscribe[i])}}};function we(t,e,r){void 0!==r&&("function"==typeof r?t.defineReactiveSetter(e,r):t[e]=r)}function Oe(t,e){if(!Oe.installed){Oe.installed=!0,zt.Vue=t;var r=t.config.optionMergeStrategies.methods;t.config.optionMergeStrategies.apollo=function(t,e,o){if(!t)return e;if(!e)return t;for(var i=Object.assign({},pt(t,$e),t.data),n=Object.assign({},pt(e,$e),e.data),s={},a=0;a<$e.length;a++){var u=$e[a];s[u]=r(t[u],e[u])}return Object.assign(s,r(i,n))},Object.defineProperty(t.prototype,"$apollo",{get:function(){return this._apollo||(this._apollo=new fe(this)),this._apollo}});var o=t.version.substr(0,t.version.indexOf("."));t.mixin(ie({},"1"===o?{init:function(){var t=void 0;t=this.$options.apolloProvider?this._apolloProvider=this.$options.apolloProvider:this.$root._apolloProvider,this.$apolloProvider=t}}:{},"2"===o?{inject:{$apolloProvider:{default:null}},data:function(){return{$apolloData:{queries:{},loading:0,data:{}}}}}:{},{created:ke,destroyed:function(){this._apollo&&(this._apollo.destroy(),this._apollo=null)}})),"2"===o&&(t.component("apollo-query",be),t.component("ApolloQuery",be),t.component("apollo-subscribe-to-more",me),t.component("ApolloSubscribeToMore",me),t.component("apollo-mutation",_e),t.component("ApolloMutation",_e))}}ve.install=Oe,ve.version="3.0.0-beta.9";var Se=ve,je=be,Ae=me,Pe=_e,xe=null;return"undefined"!=typeof window?xe=window.Vue:"undefined"!=typeof global&&(xe=global.Vue),xe&&xe.use(ve),t.install=Oe,t.ApolloProvider=Se,t.ApolloQuery=je,t.ApolloSubscribeToMore=Ae,t.ApolloMutation=Pe,t.default=ve,t.willPrefetch=ye,t}({}); +var VueApollo=function(t){"use strict";var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},r=200,o="__lodash_hash_undefined__",i=1/0,n=9007199254740991,s="[object Arguments]",a="[object Function]",u="[object GeneratorFunction]",l="[object Symbol]",c=/^\[object .+?Constructor\]$/,h=/^(?:0|[1-9]\d*)$/,p="object"==typeof e&&e&&e.Object===Object&&e,f="object"==typeof self&&self&&self.Object===Object&&self,v=p||f||Function("return this")();function d(t,e){return!!(t?t.length:0)&&function(t,e,r){if(e!=e)return function(t,e,r,o){var i=t.length,n=r+(o?1:-1);for(;o?n--:++n-1}function y(t,e,r){for(var o=-1,i=t?t.length:0;++o-1},K.prototype.set=function(t,e){var r=this.__data__,o=H(r,t);return o<0?r.push([t,e]):r[o][1]=e,this},I.prototype.clear=function(){this.__data__={hash:new V,map:new(R||K),string:new V}},I.prototype.delete=function(t){return U(this,t).delete(t)},I.prototype.get=function(t){return U(this,t).get(t)},I.prototype.has=function(t){return U(this,t).has(t)},I.prototype.set=function(t,e){return U(this,t).set(t,e),this},F.prototype.add=F.prototype.push=function(t){return this.__data__.set(t,o),this},F.prototype.has=function(t){return this.__data__.has(t)};var X=C?$(C,Object):ht,Y=C?function(t){for(var e=[];t;)g(e,X(t)),t=E(t);return e}:ht;function Z(t){return nt(t)||rt(t)||!!(T&&t&&t[T])}function tt(t,e){return!!(e=null==e?n:e)&&("number"==typeof t||h.test(t))&&t>-1&&t%1==0&&t-1&&t%1==0&&t<=n}(t.length)&&!at(t)}function at(t){var e=ut(t)?x.call(t):"";return e==a||e==u}function ut(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function lt(t){return!!t&&"object"==typeof t}function ct(t){return st(t)?W(t,!0):J(t)}function ht(){return[]}var pt=(ot=function(t,e){return null==t?{}:(e=b(function t(e,r,o,i,n){var s=-1,a=e.length;for(o||(o=Z),n||(n=[]);++s0&&o(u)?r>1?t(u,r-1,o,i,n):g(n,u):i||(n[n.length]=u)}return n}(e,1),et),function(t,e){return function(t,e,r){for(var o=-1,i=e.length,n={};++o=r&&(a=_,u=!1,e=new F(e));t:for(;++s=e||r<0||h&&t-l>=n}function d(){var t=At();if(v(t))return y(t);a=setTimeout(d,function(t){var r=e-(t-u);return h?jt(r,n-(t-l)):r}(t))}function y(t){return a=void 0,p&&o?f(t):(o=i=void 0,s)}function b(){var t=At(),r=v(t);if(o=arguments,i=this,u=t,r){if(void 0===a)return function(t){return l=t,a=setTimeout(d,e),c?f(t):s}(u);if(h)return a=setTimeout(d,e),f(u)}return void 0===a&&(a=setTimeout(d,e)),s}return e=qt(e)||0,xt(r)&&(c=!!r.leading,n=(h="maxWait"in r)?St(qt(r.maxWait)||0,e):n,p="trailing"in r?!!r.trailing:p),b.cancel=function(){void 0!==a&&clearTimeout(a),l=0,o=u=i=a=void 0},b.flush=function(){return void 0===a?s:y(At())},b}function xt(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function qt(t){if("number"==typeof t)return t;if(function(t){return"symbol"==typeof t||function(t){return!!t&&"object"==typeof t}(t)&&Ot.call(t)==dt}(t))return vt;if(xt(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=xt(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(yt,"");var r=gt.test(t);return r||mt.test(t)?_t(t.slice(2),r?2:8):bt.test(t)?vt:+t}var Qt=function(t,e,r){var o=!0,i=!0;if("function"!=typeof t)throw new TypeError(ft);return xt(r)&&(o="leading"in r?!!r.leading:o,i="trailing"in r?!!r.trailing:i),Pt(t,e,{leading:o,maxWait:e,trailing:i})},Et="Expected a function",Lt=NaN,Dt="[object Symbol]",Tt=/^\s+|\s+$/g,Ct=/^[-+]0x[0-9a-f]+$/i,Mt=/^0b[01]+$/i,Rt=/^0o[0-7]+$/i,Nt=parseInt,Vt="object"==typeof e&&e&&e.Object===Object&&e,Kt="object"==typeof self&&self&&self.Object===Object&&self,It=Vt||Kt||Function("return this")(),Ft=Object.prototype.toString,Wt=Math.max,Ht=Math.min,Gt=function(){return It.Date.now()};function Jt(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function Bt(t){if("number"==typeof t)return t;if(function(t){return"symbol"==typeof t||function(t){return!!t&&"object"==typeof t}(t)&&Ft.call(t)==Dt}(t))return Lt;if(Jt(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=Jt(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(Tt,"");var r=Mt.test(t);return r||Rt.test(t)?Nt(t.slice(2),r?2:8):Ct.test(t)?Lt:+t}var Ut=function(t,e,r){var o,i,n,s,a,u,l=0,c=!1,h=!1,p=!0;if("function"!=typeof t)throw new TypeError(Et);function f(e){var r=o,n=i;return o=i=void 0,l=e,s=t.apply(n,r)}function v(t){var r=t-u;return void 0===u||r>=e||r<0||h&&t-l>=n}function d(){var t=Gt();if(v(t))return y(t);a=setTimeout(d,function(t){var r=e-(t-u);return h?Ht(r,n-(t-l)):r}(t))}function y(t){return a=void 0,p&&o?f(t):(o=i=void 0,s)}function b(){var t=Gt(),r=v(t);if(o=arguments,i=this,u=t,r){if(void 0===a)return function(t){return l=t,a=setTimeout(d,e),c?f(t):s}(u);if(h)return a=setTimeout(d,e),f(u)}return void 0===a&&(a=setTimeout(d,e)),s}return e=Bt(e)||0,Jt(r)&&(c=!!r.leading,n=(h="maxWait"in r)?Wt(Bt(r.maxWait)||0,e):n,p="trailing"in r?!!r.trailing:p),b.cancel=function(){void 0!==a&&clearTimeout(a),l=0,o=u=i=a=void 0},b.flush=function(){return void 0===a?s:y(Gt())},b},zt={};function Xt(t){return function(e,r){return"number"==typeof r?t(e,r):t(e,r.wait,r)}}var Yt=Xt(Qt),Zt=Xt(Ut);function te(t,e){for(;"function"==typeof t;)t=t.call(e);return t}var ee="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},re=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},oe=function(){function t(t,e){for(var r=0;r3&&void 0!==arguments[3])||arguments[3];if(re(this,t),this.type=null,this.vueApolloSpecialKeys=[],this.vm=e,this.key=r,this.options=Object.assign({},o),this._skip=!1,this._watchers=[],this._destroyed=!1,"function"==typeof this.options.query){var s=this.options.query.bind(this.vm);this.options.query=s(),this._watchers.push(this.vm.$watch(s,function(t){i.options.query=t,i.refresh()}))}if("function"==typeof this.options.document){var a=this.options.document.bind(this.vm);this.options.document=a(),this._watchers.push(this.vm.$watch(a,function(t){i.options.document=t,i.refresh()}))}if("function"==typeof this.options.context){var u=this.options.context.bind(this.vm);this.options.context=u(),this._watchers.push(this.vm.$watch(u,function(t){i.options.context=t,i.refresh()}))}this.vm.$isServer&&(this.options.fetchPolicy="cache-first"),n&&this.autostart()}return oe(t,[{key:"autostart",value:function(){"function"==typeof this.options.skip?this._watchers.push(this.vm.$watch(this.options.skip.bind(this.vm),this.skipChanged.bind(this),{immediate:!0})):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.options.variables){var e=this.executeApollo.bind(this);e=this.options.throttle?Yt(e,this.options.throttle):e,e=this.options.debounce?Zt(e,this.options.debounce):e,this.unwatchVariables=this.vm.$watch(function(){return t.options.variables.call(t.vm)},e,{immediate:!0})}else this.executeApollo(this.options.variables)}},{key:"stop",value:function(){this.unwatchVariables&&(this.unwatchVariables(),this.unwatchVariables=null),this.sub&&(this.sub.unsubscribe(),this.sub=null)}},{key:"generateApolloOptions",value:function(t){var e=pt(this.options,this.vueApolloSpecialKeys);return e.variables=t,e}},{key:"executeApollo",value:function(t){this.starting=!1}},{key:"nextResult",value:function(){throw new Error("Not implemented")}},{key:"errorHandler",value:function(){for(var t,e,r,o=arguments.length,i=Array(o),n=0;n3&&void 0!==arguments[3])||arguments[3];(re(this,e),o.query)||(o={query:o});t.$data.$apolloData&&!t.$data.$apolloData.queries[r]&&t.$set(t.$data.$apolloData.queries,r,{loading:!1});var n=ae(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,r,o,i));return n.type="query",n.vueApolloSpecialKeys=ce,n._loading=!1,n}return se(e,le),oe(e,[{key:"stop",value:function(){ne(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"stop",this).call(this),this.observer&&(this.observer.stopPolling(),this.observer=null)}},{key:"executeApollo",value:function(t){this.observer?this.observer.setOptions(this.generateApolloOptions(t)):(this.sub&&this.sub.unsubscribe(),this.observer=this.vm.$apollo.watchQuery(this.generateApolloOptions(t)),this.sub=this.observer.subscribe({next:this.nextResult.bind(this),error:this.catchError.bind(this)}));var r=this.maySetLoading();r.loading||this.nextResult(r),ne(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"executeApollo",this).call(this,t)}},{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){var e=t.data;t.loading||this.loadingDone();var r="function"==typeof this.options.result;void 0===e||(this.options.manual?r||console.error(this.key+" query must have a 'result' hook in manual mode"):"function"==typeof this.options.update?this.vm.$set(this.vm.$data.$apolloData.data,this.key,this.options.update.call(this.vm,e)):void 0===e[this.key]?console.error("Missing "+this.key+" attribute on result",e):this.vm.$set(this.vm.$data.$apolloData.data,this.key,e[this.key])),r&&this.options.result.call(this.vm,t)}},{key:"catchError",value:function(t){ne(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"catchError",this).call(this,t),this.loadingDone()}},{key:"watchLoading",value:function(){for(var t,e,r,o=arguments.length,i=Array(o),n=0;n0&&void 0!==arguments[0]?arguments[0]:null;if(!t||!t.client){if("object"===ee(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 r=this.provider.clients[t.client];if(!r)throw new Error("[vue-apollo] Missing client '"+t.client+"' in 'apolloProvider'");return r}},{key:"watchQuery",value:function(t){var e=this,r=this.getClient(t).watchQuery(t),o=r.subscribe.bind(r);return r.subscribe=function(t){var r=o(t);return e._apolloSubscriptions.push(r),r},r}},{key:"mutate",value:function(t){return this.getClient(t).mutate(t)}},{key:"subscribe",value:function(t){var e=this;if(!this.vm.$isServer){var r=this.getClient(t).subscribe(t),o=r.subscribe.bind(r);return r.subscribe=function(t){var r=o(t);return e._apolloSubscriptions.push(r),r},r}}},{key:"addSmartQuery",value:function(t,e){var r=this;e=te(e,this.vm);var o=this.queries[t]=new he(this.vm,t,e,!1);if(o.autostart(),!this.vm.$isServer){var i=e.subscribeToMore;i&&(Array.isArray(i)?i.forEach(function(e,i){r.addSmartSubscription(""+t+i,ie({},e,{linkedQuery:o}))}):this.addSmartSubscription(t,ie({},i,{linkedQuery:o})))}return o}},{key:"addSmartSubscription",value:function(t,e){if(!this.vm.$isServer){e=te(e,this.vm);var r=this.subscriptions[t]=new pe(this.vm,t,e,!1);return r.autostart(),r}}},{key:"defineReactiveSetter",value:function(t,e){var r=this;this._watchers.push(this.vm.$watch(e,function(e){r[t]=e},{immediate:!0}))}},{key:"destroy",value:function(){var t=!0,e=!1,r=void 0;try{for(var o,i=this._watchers[Symbol.iterator]();!(t=(o=i.next()).done);t=!0){(0,o.value)()}}catch(t){e=!0,r=t}finally{try{!t&&i.return&&i.return()}finally{if(e)throw r}}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 this.vm.$data.$apolloData&&0!==this.vm.$data.$apolloData.loading}},{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}(),ve=function(){function t(e){if(re(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 oe(t,[{key:"provide",value:function(){return function(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}({},arguments.length>0&&void 0!==arguments[0]?arguments[0]:"$apolloProvider",this)}},{key:"addQueryToPrefetch",value:function(t,e){this.prefetchQueries.push({queryOptions:t,client:e})}},{key:"prefetchComponent",value:function(t,e){var r;r=t;var o=(t=zt.Vue.util.mergeOptions({},r)).apollo;if(o){var i=o.$client;for(var n in o){var s=o[n];"$"===n.charAt(0)||s.query&&(void 0!==s.ssr&&!s.ssr||void 0===s.prefetch||!s.prefetch)||this.addQueryToPrefetch(s,s.client||i)}}}},{key:"prefetchComponents",value:function(t){var e=!0,r=!1,o=void 0;try{for(var i,n=t[Symbol.iterator]();!(e=(i=n.next()).done);e=!0){var s=i.value;this.prefetchComponent(s)}}catch(t){r=!0,o=t}finally{try{!e&&n.return&&n.return()}finally{if(r)throw o}}}},{key:"prefetchAll",value:function(t,e,r){var o=this;r||!e||Array.isArray(e)||(r=e,e=void 0);var i=Object.assign({},{includeGlobal:!0},r);return e&&this.prefetchComponents(e),i.includeGlobal&&this.prefetchComponents(de.filter(function(e){e.component;var r=e.contextCallback,o=!0;return"function"==typeof r&&(o=!!r(t)),o}).map(function(t){return t.component}),t),Promise.all(this.prefetchQueries.map(function(e){return o.prefetchQuery(e.queryOptions,t,e.client)}))}},{key:"prefetchQuery",value:function(t,e,r){var o=void 0;if(r){if("string"==typeof r&&!(r=this.clients[r]))throw new Error("[vue-apollo] Missing client '"+r+"' in 'apolloProvider'")}else r=this.defaultClient;if(t.query){var i=t.prefetch,n=void 0===i?"undefined":ee(i);if("undefined"!==n){var s=void 0;if(!(s="function"===n?i(e):i))return Promise.resolve();if("boolean"===n){var a=t.variables;o=void 0!==a?"function"==typeof a?a.call(e):a:void 0}else o=s}}else t={query:t};return"function"==typeof t.query&&(t.query=t.query(e)),new Promise(function(e,i){var n=pt(t,[].concat(ue(ce),["fetchPolicy"]));n.variables=o,n.fetchPolicy="network-only",r.query(n).then(e,i)})}},{key:"getStates",value:function(t){var e=Object.assign({},{exportNamespace:""},t),r={};for(var o in this.clients){var i=this.clients[o].cache.extract();r[""+e.exportNamespace+o]=i}return r}},{key:"exportStates",value:function(t){var e=Object.assign({},{globalName:"__APOLLO_STATE__",attachTo:"window"},t),r=this.getStates(e);return e.attachTo+"."+e.globalName+" = "+JSON.stringify(r)+";"}}]),t}(),de=[];function ye(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return de.push({component:t,contextCallback:e}),t}"undefined"!=typeof window?window.vueApolloWillPrefetch=ye:"undefined"!=typeof global&&(global.vueApolloWillPrefetch=ye);var be={name:"ApolloQuery",provide:function(){return{getDollarApollo:this.getDollarApollo,getApolloQuery:this.getApolloQuery}},props:{query:{type:Object,required:!0},variables:{type:Object,default:null},fetchPolicy:{type:String,default:"cache-first"},pollInterval:{type:Number,default:0},notifyOnNetworkStatusChange:{type:Boolean,default:!1},context:{type:Object,default:null},skip:{type:Boolean,default:!1},clientId:{type:String,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,notifyOnNetworkStatusChange:this.notifyOnNetworkStatusChange,context:function(){return this.context},skip:function(){return this.skip},manual:!0,result:function(t){var e=t,r=e.errors,o=e.loading,i=e.networkStatus,n=t.error;t=Object.assign({},t),r&&r.length&&((n=new Error("Apollo errors occured ("+r.length+")")).graphQLErrors=r);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:i,times:++this.$_times},this.$emit("result",this.result)},error:function(t){this.result.loading=!1,this.result.error=t,console.log(this.$apollo.queries.query.observer.currentResult()),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,query:this.$apollo.queries.query});return e=Array.isArray(e)?e.concat(this.$slots.default):[e].concat(this.$slots.default),t(this.tag,e)}},ge=0,me={name:"ApolloSubscribeToMore",inject:["getDollarApollo","getApolloQuery"],props:{document:{type:Object,required:!0},variables:{type:Object,default:null},updateQuery:{type:Function,default:null}},watch:{document:"refresh",variables:"refresh"},created:function(){this.$_key="sub_component_"+ge++},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}},_e={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},tag:{type:String,default:"div"}},data:function(){return{loading:!1,error:null}},methods:{mutate:function(t){var e,r=this;return(e=regeneratorRuntime.mark(function e(){var o;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return r.loading=!0,r.error=null,e.prev=2,e.next=5,r.$apollo.mutate(ie({mutation:r.mutation,variables:r.variables,optimisticResponse:r.optimisticResponse,update:r.update,refetchQueries:r.refetchQueries},t));case 5:o=e.sent,r.$emit("done",o),e.next=13;break;case 9:e.prev=9,e.t0=e.catch(2),r.error=e.t0,r.$emit("error",e.t0);case 13:r.loading=!1;case 14:case"end":return e.stop()}},e,r,[[2,9]])}),function(){var t=e.apply(this,arguments);return new Promise(function(e,r){return function o(i,n){try{var s=t[i](n),a=s.value}catch(t){return void r(t)}if(!s.done)return Promise.resolve(a).then(function(t){o("next",t)},function(t){o("throw",t)});e(a)}("next")})})()}},render:function(t){var e=this.$scopedSlots.default({mutate:this.mutate,loading:this.loading,error:this.error});return e=Array.isArray(e)?e.concat(this.$slots.default):[e].concat(this.$slots.default),t(this.tag,e)}},$e=["$subscribe"],ke=function(){var t=this,e=this.$apolloProvider;if(!this._apolloLaunched&&e){this._apolloLaunched=!0;var r=this.$options.apollo;if(r){r.$init||(r.$init=!0,e.defaultOptions&&(r=this.$options.apollo=Object.assign({},e.defaultOptions,r))),we(this.$apollo,"skipAll",r.$skipAll),we(this.$apollo,"skipAllQueries",r.$skipAllQueries),we(this.$apollo,"skipAllSubscriptions",r.$skipAllSubscriptions),we(this.$apollo,"client",r.$client),we(this.$apollo,"loadingKey",r.$loadingKey),we(this.$apollo,"error",r.$error),we(this.$apollo,"watchLoading",r.$watchLoading);var o=function(e){if("$"!==e.charAt(0)){var o=!1;void 0!==t.$props&&(o=t.$props.hasOwnProperty(e)),t.hasOwnProperty(e)||o||t.$data.hasOwnProperty(e)||Object.defineProperty(t,e,{get:function(){return t.$data.$apolloData.data[e]},enumerable:!0,configurable:!0}),t.$apollo.addSmartQuery(e,r[e])}};for(var i in r)o(i);if(r.subscribe&&zt.Vue.util.warn("vue-apollo -> `subscribe` option is deprecated. Use the `$subscribe` option instead."),r.$subscribe)for(var i in r.$subscribe)this.$apollo.addSmartSubscription(i,r.$subscribe[i])}}};function we(t,e,r){void 0!==r&&("function"==typeof r?t.defineReactiveSetter(e,r):t[e]=r)}function Oe(t,e){if(!Oe.installed){Oe.installed=!0,zt.Vue=t;var r=t.config.optionMergeStrategies.methods;t.config.optionMergeStrategies.apollo=function(t,e,o){if(!t)return e;if(!e)return t;for(var i=Object.assign({},pt(t,$e),t.data),n=Object.assign({},pt(e,$e),e.data),s={},a=0;a<$e.length;a++){var u=$e[a];s[u]=r(t[u],e[u])}return Object.assign(s,r(i,n))},Object.defineProperty(t.prototype,"$apollo",{get:function(){return this._apollo||(this._apollo=new fe(this)),this._apollo}});var o=t.version.substr(0,t.version.indexOf("."));t.mixin(ie({},"1"===o?{init:function(){var t=void 0;t=this.$options.apolloProvider?this._apolloProvider=this.$options.apolloProvider:this.$root._apolloProvider,this.$apolloProvider=t}}:{},"2"===o?{inject:{$apolloProvider:{default:null}},data:function(){return{$apolloData:{queries:{},loading:0,data:{}}}}}:{},{created:ke,destroyed:function(){this._apollo&&(this._apollo.destroy(),this._apollo=null)}})),"2"===o&&(t.component("apollo-query",be),t.component("ApolloQuery",be),t.component("apollo-subscribe-to-more",me),t.component("ApolloSubscribeToMore",me),t.component("apollo-mutation",_e),t.component("ApolloMutation",_e))}}ve.install=Oe,ve.version="3.0.0-beta.9";var Se=ve,je=be,Ae=me,Pe=_e,xe=null;return"undefined"!=typeof window?xe=window.Vue:"undefined"!=typeof global&&(xe=global.Vue),xe&&xe.use(ve),t.install=Oe,t.ApolloProvider=Se,t.ApolloQuery=je,t.ApolloSubscribeToMore=Ae,t.ApolloMutation=Pe,t.default=ve,t.willPrefetch=ye,t}({}); diff --git a/dist/vue-apollo.umd.js b/dist/vue-apollo.umd.js index e0d0ee9..81ca833 100644 --- a/dist/vue-apollo.umd.js +++ b/dist/vue-apollo.umd.js @@ -3927,7 +3927,12 @@ var launch = function launch() { var _loop = function _loop(key) { if (key.charAt(0) !== '$') { - if (!_this.hasOwnProperty(key) && !_this.$props.hasOwnProperty(key) && !_this.$data.hasOwnProperty(key)) { + var propHasKeyProperty = false; + if (typeof _this.$props !== 'undefined') { + propHasKeyProperty = _this.$props.hasOwnProperty(key); + } + + if (!_this.hasOwnProperty(key) && !propHasKeyProperty && !_this.$data.hasOwnProperty(key)) { Object.defineProperty(_this, key, { get: function get$$1() { return _this.$data.$apolloData.data[key]; diff --git a/src/index.js b/src/index.js index c16b763..bfa9ea1 100644 --- a/src/index.js +++ b/src/index.js @@ -40,7 +40,12 @@ const launch = function launch () { // watchQuery for (let key in apollo) { if (key.charAt(0) !== '$') { - if (!this.hasOwnProperty(key) && !this.$props.hasOwnProperty(key) && !this.$data.hasOwnProperty(key)) { + let propHasKeyProperty = false + if (typeof this.$props !== 'undefined') { + propHasKeyProperty = this.$props.hasOwnProperty(key) + } + + if (!this.hasOwnProperty(key) && !propHasKeyProperty && !this.$data.hasOwnProperty(key)) { Object.defineProperty(this, key, { get: () => this.$data.$apolloData.data[key], enumerable: true,