2 lines
27 KiB
JavaScript
2 lines
27 KiB
JavaScript
var VueApollo=function(t,o){"use strict";function r(t){return(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})(t)}function s(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function n(t,e){for(var i=0;i<e.length;i++){var o=e[i];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}function i(t,e,i){return e&&n(t.prototype,e),i&&n(t,i),t}function a(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function l(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),i.push.apply(i,o)}return i}function c(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?l(i,!0).forEach(function(t){a(e,t,i[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):l(i).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))})}return e}function e(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&h(t,e)}function u(t){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function h(t,e){return(h=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function p(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function f(t,e){return!e||"object"!=typeof e&&"function"!=typeof e?p(t):e}function d(t,e,i){return(d="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,i){var o=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=u(t)););return t}(t,e);if(o){var r=Object.getOwnPropertyDescriptor(o,e);return r.get?r.get.call(i):r.value}})(t,e,i||t)}function v(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){if(!(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t)))return;var i=[],o=!0,r=!1,n=void 0;try{for(var s,a=t[Symbol.iterator]();!(o=(s=a.next()).done)&&(i.push(s.value),!e||i.length!==e);o=!0);}catch(t){r=!0,n=t}finally{try{o||null==a.return||a.return()}finally{if(r)throw n}}return i}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function y(t){return function(t){if(Array.isArray(t)){for(var e=0,i=new Array(t.length);e<t.length;e++)i[e]=t[e];return i}}(t)||function(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function b(r,n,s,a){var l,u=!1,c=0;function h(){l&&clearTimeout(l)}function t(){var t=this,e=Date.now()-c,i=arguments;function o(){c=Date.now(),s.apply(t,i)}u||(a&&!l&&o(),h(),void 0===a&&r<e?o():!0!==n&&(l=setTimeout(a?function(){l=void 0}:o,void 0===a?r-e:r)))}return"boolean"!=typeof n&&(a=s,s=n,n=void 0),t.cancel=function(){h(),u=!0},t}o=o&&o.hasOwnProperty("default")?o.default:o;var g,m=Object.freeze({throttle:b,debounce:function(t,e,i){return void 0===i?b(t,e,!1):b(t,i,!1!==e)}}),$=(function(t,e){var i=e.Globals={};function o(i){return function(t,e){return i(e,t)}}e.throttle=o(m.throttle),e.debounce=o(m.debounce),e.getMergedDefinition=function(t){return i.Vue.util.mergeOptions({},t)},e.reapply=function(t,e){for(;"function"==typeof t;)t=t.call(e);return t},e.omit=function(t,i){return Object.entries(t).filter(function(t){var e=v(t,1)[0];return!i.includes(e)}).reduce(function(t,e){var i=v(e,2),o=i[0],r=i[1];return t[o]=r,t},{})},e.addGqlError=function(t){t.graphQLErrors&&t.graphQLErrors.length&&(t.gqlError=t.graphQLErrors[0])},e.noop=function(){}}(g={exports:{}},g.exports),g.exports),k=$.Globals,w=$.throttle,O=$.debounce,S=($.getMergedDefinition,$.reapply),_=$.omit,A=$.addGqlError,j=($.noop,function(){function r(t,e,i){var o=!(3<arguments.length&&void 0!==arguments[3])||arguments[3];s(this,r),a(this,"type",null),a(this,"vueApolloSpecialKeys",[]),this.vm=t,this.key=e,this.initialOptions=i,this.options=Object.assign({},i),this._skip=!1,this._pollInterval=null,this._watchers=[],this._destroyed=!1,o&&this.autostart()}return i(r,[{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(),"function"==typeof this.options.pollInterval&&(this._pollWatcher=this.vm.$watch(this.options.pollInterval.bind(this.vm),this.pollIntervalChanged.bind(this),{immediate:!0}))}},{key:"pollIntervalChanged",value:function(t,e){t!==e&&(null==(this.pollInterval=t)?this.stopPolling():this.startPolling(t))}},{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 o=this;this.starting=!0;for(var t=function(){var e=n[r];if("function"==typeof o.initialOptions[e]){var t=o.initialOptions[e].bind(o.vm);o.options[e]=t();var i=function(t){o.options[e]=t,o.refresh()};i=o.options.throttle?w(i,o.options.throttle):i,i=o.options.debounce?O(i,o.options.debounce):i,o._watchers.push(o.vm.$watch(t,i,{deep:o.options.deep}))}},r=0,n=["query","document","context"];r<n.length;r++)t();if("function"==typeof this.options.variables){var e=this.executeApollo.bind(this);e=this.options.throttle?w(e,this.options.throttle):e,e=this.options.debounce?O(e,this.options.debounce):e,this._watchers.push(this.vm.$watch(function(){return o.options.variables.call(o.vm)},e,{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||null==r.return||r.return()}finally{if(e)throw i}}this.sub&&(this.sub.unsubscribe(),this.sub=null)}},{key:"generateApolloOptions",value:function(t){var e=_(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&&A(e)}},{key:"callHandlers",value:function(t){for(var e=!1,i=arguments.length,o=new Array(1<i?i-1:0),r=1;r<i;r++)o[r-1]=arguments[r];var n=!0,s=!1,a=void 0;try{for(var l,u=t[Symbol.iterator]();!(n=(l=u.next()).done);n=!0){var c=l.value;if(c){e=!0;var h=c.apply(this.vm,o);if(void 0!==h&&!h)break}}}catch(t){s=!0,a=t}finally{try{n||null==u.return||u.return()}finally{if(s)throw a}}return e}},{key:"errorHandler",value:function(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];return this.callHandlers.apply(this,[[this.options.error,this.vm.$apollo.error,this.vm.$apollo.provider.errorHandler]].concat(e))}},{key:"catchError",value:function(t){if(A(t),!this.errorHandler(t))if(t.graphQLErrors&&0!==t.graphQLErrors.length){console.error("GraphQL execution errors for ".concat(this.type," '").concat(this.key,"'"));var e=!0,i=!1,o=void 0;try{for(var r,n=t.graphQLErrors[Symbol.iterator]();!(e=(r=n.next()).done);e=!0){var s=r.value;console.error(s)}}catch(t){i=!0,o=t}finally{try{e||null==n.return||n.return()}finally{if(i)throw o}}}else if(t.networkError)console.error("Error sending the ".concat(this.type," '").concat(this.key,"'"),t.networkError);else{var a;if(console.error("[vue-apollo] An error has occurred for ".concat(this.type," '").concat(this.key,"'")),Array.isArray(t))(a=console).error.apply(a,y(t));else console.error(t)}}},{key:"destroy",value:function(){this._destroyed||(this._destroyed=!0,this.stop(),this._skipWatcher&&this._skipWatcher())}},{key:"pollInterval",get:function(){return this._pollInterval},set:function(t){this._pollInterval=t}},{key:"skip",get:function(){return this._skip},set:function(t){t?this.stop():this.start(),this._skip=t}}]),r}()),P=["variables","watch","update","result","error","loadingKey","watchLoading","skip","throttle","debounce","subscribeToMore","prefetch","manual"],q=function(){function n(t,e,i){var o,r=!(3<arguments.length&&void 0!==arguments[3])||arguments[3];s(this,n),i.query||(i={query:i});return t.$data.$apolloData&&!t.$data.$apolloData.queries[e]&&t.$set(t.$data.$apolloData.queries,e,{loading:!1}),a(p(o=f(this,u(n).call(this,t,e,i,!1))),"type","query"),a(p(o),"vueApolloSpecialKeys",P),a(p(o),"_loading",!1),t.$isServer&&(o.firstRun=new Promise(function(t,e){o._firstRunResolve=t,o._firstRunReject=e})),o.vm.$isServer&&(o.options.fetchPolicy="network-only"),i.manual||(o.hasDataField=o.vm.$data.hasOwnProperty(e),o.hasDataField?Object.defineProperty(o.vm.$data.$apolloData.data,e,{get:function(){return o.vm.$data[e]},enumerable:!0,configurable:!0}):Object.defineProperty(o.vm.$data,e,{get:function(){return o.vm.$data.$apolloData.data[e]},enumerable:!0,configurable:!0})),r&&o.autostart(),o}return e(n,j),i(n,[{key:"stop",value:function(){d(u(n.prototype),"stop",this).call(this),this.loadingDone(),this.observer&&(this.observer.stopPolling(),this.observer=null)}},{key:"executeApollo",value:function(t){var e=JSON.stringify(t);if(this.sub){if(e===this.previousVariablesJson)return;this.sub.unsubscribe()}if(this.previousVariablesJson=e,this.observer=this.vm.$apollo.watchQuery(this.generateApolloOptions(t)),this.startQuerySubscription(),"no-cache"!==this.options.fetchPolicy||this.options.notifyOnNetworkStatusChange){var i=this.maySetLoading();i.loading&&!this.options.notifyOnNetworkStatusChange||this.nextResult(i)}d(u(n.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(t){var e=0<arguments.length&&void 0!==t&&t,i=this.observer.currentResult();return(e||i.loading)&&(this.loading||this.applyLoadingModifier(1),this.loading=!0),i}},{key:"nextResult",value:function(t){d(u(n.prototype),"nextResult",this).call(this,t);var e=t.data,i=t.loading;t.error&&this.firstRunReject(),i||this.loadingDone();var o="function"==typeof this.options.result;null==e||(this.options.manual?o||console.error("".concat(this.key," query must have a 'result' hook in manual mode")):"function"==typeof this.options.update?this.setData(this.options.update.call(this.vm,e)):void 0===e[this.key]&&Object.keys(e).length?console.error("Missing ".concat(this.key," attribute on result"),e):this.setData(e[this.key])),o&&this.options.result.call(this.vm,t,this.key)}},{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){d(u(n.prototype),"catchError",this).call(this,t),this.firstRunReject(),this.loadingDone(t),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=new Array(t),i=0;i<t;i++)e[i]=arguments[i];return this.callHandlers.apply(this,[[this.options.watchLoading,this.vm.$apollo.watchLoading,this.vm.$apollo.provider.watchLoading]].concat(e,[this]))}},{key:"applyLoadingModifier",value:function(t){var e=this.loadingKey;e&&"number"==typeof this.vm[e]&&(this.vm[e]+=t),this.watchLoading(1===t,t)}},{key:"loadingDone",value:function(t){var e=0<arguments.length&&void 0!==t?t:null;this.loading&&this.applyLoadingModifier(-1),this.loading=!1,e||this.firstRunResolve()}},{key:"fetchMore",value:function(){var t,e=this;if(this.observer)return this.maySetLoading(!0),(t=this.observer).fetchMore.apply(t,arguments).then(function(t){return t.loading||e.loadingDone(),t})}},{key:"subscribeToMore",value:function(){var t;if(this.observer)return{unsubscribe:(t=this.observer).subscribeToMore.apply(t,arguments)}}},{key:"refetch",value:function(t){var e=this;if(t&&(this.options.variables=t),this.observer){var i=this.observer.refetch(t).then(function(t){return t.loading||e.loadingDone(),t});return this.maySetLoading(),i}}},{key:"setVariables",value:function(t,e){if(this.options.variables=t,this.observer){var i=this.observer.setVariables(t,e);return this.maySetLoading(),i}}},{key:"setOptions",value:function(t){if(Object.assign(this.options,t),this.observer){var e=this.observer.setOptions(t);return this.maySetLoading(),e}}},{key:"startPolling",value:function(){var t;if(this.observer)return(t=this.observer).startPolling.apply(t,arguments)}},{key:"stopPolling",value:function(){var t;if(this.observer)return(t=this.observer).stopPolling.apply(t,arguments)}},{key:"firstRunResolve",value:function(){this._firstRunResolve&&(this._firstRunResolve(),this._firstRunResolve=null)}},{key:"firstRunReject",value:function(t){this._firstRunReject&&(this._firstRunReject(t),this._firstRunReject=null)}},{key:"destroy",value:function(){d(u(n.prototype),"destroy",this).call(this),this.loading&&this.watchLoading(!1,-1),this.loading=!1}},{key:"client",get:function(){return this.vm.$apollo.getClient(this.options)}},{key:"loading",get:function(){return this.vm.$data.$apolloData&&this.vm.$data.$apolloData.queries[this.key]?this.vm.$data.$apolloData.queries[this.key].loading:this._loading},set:function(t){this._loading!==t&&(this._loading=t,this.vm.$data.$apolloData&&this.vm.$data.$apolloData.queries[this.key]&&(this.vm.$data.$apolloData.queries[this.key].loading=t,this.vm.$data.$apolloData.loading+=t?1:-1))}},{key:"loadingKey",get:function(){return this.options.loadingKey||this.vm.$apollo.loadingKey}}]),n}(),D=function(){function n(){var t,e;s(this,n);for(var i=arguments.length,o=new Array(i),r=0;r<i;r++)o[r]=arguments[r];return a(p(e=f(this,(t=u(n)).call.apply(t,[this].concat(o)))),"type","subscription"),a(p(e),"vueApolloSpecialKeys",["variables","result","error","throttle","debounce","linkedQuery"]),e}return e(n,j),i(n,[{key:"executeApollo",value:function(t){var e=JSON.stringify(t);if(this.sub){if(e===this.previousVariablesJson)return;this.sub.unsubscribe()}this.previousVariablesJson=e;var i=this.generateApolloOptions(t);if("function"==typeof i.updateQuery&&(i.updateQuery=i.updateQuery.bind(this.vm)),this.options.linkedQuery){if("function"==typeof this.options.result){var o=this.options.result.bind(this.vm),r=i.updateQuery&&i.updateQuery.bind(this.vm);i.updateQuery=function(){return o.apply(void 0,arguments),r&&r.apply(void 0,arguments)}}this.sub=this.options.linkedQuery.subscribeToMore(i)}else this.observer=this.vm.$apollo.subscribe(i),this.sub=this.observer.subscribe({next:this.nextResult.bind(this),error:this.catchError.bind(this)});d(u(n.prototype),"executeApollo",this).call(this,t)}},{key:"nextResult",value:function(t){d(u(n.prototype),"nextResult",this).call(this,t),"function"==typeof this.options.result&&this.options.result.call(this.vm,t,this.key)}}]),n}(),R=function(){function e(t){s(this,e),this._apolloSubscriptions=[],this._watchers=[],this.vm=t,this.queries={},this.subscriptions={},this.client=void 0,this.loadingKey=void 0,this.error=void 0}return i(e,[{key:"getClient",value:function(t){var e=0<arguments.length&&void 0!==t?t:null;if(!e||!e.client){if("object"===r(this.client))return this.client;if(this.client){if(this.provider.clients){var i=this.provider.clients[this.client];if(!i)throw new Error("[vue-apollo] Missing client '".concat(this.client,"' in 'apolloProvider'"));return i}throw new Error("[vue-apollo] Missing 'clients' options in 'apolloProvider'")}return this.provider.defaultClient}var o=this.provider.clients[e.client];if(!o)throw new Error("[vue-apollo] Missing client '".concat(e.client,"' in 'apolloProvider'"));return o}},{key:"query",value:function(t){return this.getClient(t).query(t)}},{key:"watchQuery",value:function(t){var i=this,e=this.getClient(t).watchQuery(t),o=e.subscribe.bind(e);return e.subscribe=function(t){var e=o(t);return i._apolloSubscriptions.push(e),e},e}},{key:"mutate",value:function(t){return this.getClient(t).mutate(t)}},{key:"subscribe",value:function(t){var i=this;if(!this.vm.$isServer){var e=this.getClient(t).subscribe(t),o=e.subscribe.bind(e);return e.subscribe=function(t){var e=o(t);return i._apolloSubscriptions.push(e),e},e}}},{key:"addSmartQuery",value:function(i,t){var e,o=this,r=S(t,this.vm),n=this.vm.$options.apollo,s=this.provider.defaultOptions;if(n&&n.$query&&(e=n.$query),n&&n.$query||!s||!s.$query||(e=s.$query),e)for(var a in e)void 0===r[a]&&(r[a]=e[a]);var l=this.queries[i]=new q(this.vm,i,r,!1);if(this.vm.$isServer&&!1===r.prefetch||l.autostart(),!this.vm.$isServer){var u=r.subscribeToMore;u&&(Array.isArray(u)?u.forEach(function(t,e){o.addSmartSubscription("".concat(i).concat(e),c({},t,{linkedQuery:l}))}):this.addSmartSubscription(i,c({},u,{linkedQuery:l})))}return l}},{key:"addSmartSubscription",value:function(t,e){if(!this.vm.$isServer){e=S(e,this.vm);var i=this.subscriptions[t]=new D(this.vm,t,e,!1);return i.autostart(),i}}},{key:"defineReactiveSetter",value:function(e,t,i){var o=this;this._watchers.push(this.vm.$watch(t,function(t){o[e]=t},{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||null==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}}]),e}(),Q=function(){function e(t){if(s(this,e),!t)throw new Error("Options argument required");this.clients=t.clients||{},this.clients.defaultClient=this.defaultClient=t.defaultClient,this.defaultOptions=t.defaultOptions,this.watchLoading=t.watchLoading,this.errorHandler=t.errorHandler,this.prefetch=t.prefetch}return i(e,[{key:"provide",value:function(t){var e=0<arguments.length&&void 0!==t?t:"$apolloProvider";return console.warn("<ApolloProvider>.provide() is deprecated. Use the 'apolloProvider' option instead with the provider object directly."),a({},e,this)}}]),e}();var E={name:"ApolloQuery",provide:function(){return{getDollarApollo:this.getDollarApollo,getApolloQuery:this.getApolloQuery}},props:{query:{type:[Function,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},update:{type:Function,default:function(t){return t}},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"},prefetch:{type:Boolean,default:!0},options:{type:Object,default:function(){return{}}}},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})},"$data.$apolloData.loading":function(t){this.$emit("loading",!!t)}},apollo:{$client:function(){return this.clientId},query:function(){return c({query:function(){return"function"==typeof this.query?this.query(o):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,prefetch:this.prefetch},this.options,{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 occurred (".concat(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);var a=function(t){return 0<Object.keys(t).length}(s);this.result={data:a?this.update(s):void 0,fullData:a?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[0]}},L=0,x={name:"ApolloSubscribeToMore",inject:["getDollarApollo","getApolloQuery"],props:{document:{type:[Function,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_".concat(L++)},mounted:function(){this.refresh()},beforeDestroy:function(){this.destroy()},methods:{destroy:function(){this.$_sub&&this.$_sub.destroy()},refresh:function(){this.destroy();var t=this.document;"function"==typeof t&&(t=t(o)),this.$_sub=this.getDollarApollo().addSmartSubscription(this.$_key,{document:t,variables:this.variables,updateQuery:this.updateQuery,linkedQuery:this.getApolloQuery()})}},render:function(t){return null}},C={props:{mutation:{type:[Function,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}},watch:{loading:function(t){this.$emit("loading",t)}},methods:{mutate:function(t){var e=this;this.loading=!0,this.error=null;var i=this.mutation;"function"==typeof i&&(i=i(o)),this.$apollo.mutate(c({mutation:i,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){A(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[0]}};function I(t,e){return void 0!==t&&Object.prototype.hasOwnProperty.call(t,e)}function M(){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&&i.$apolloProvider&&(this.$apolloProvider=i.$apolloProvider)}}function T(){var t=this,e=this.$apolloProvider;if(!this._apolloLaunched&&e){this._apolloLaunched=!0;var i=this.$options.apollo;if(i){for(var o in this.$_apolloPromises=[],i.$init||(i.$init=!0,e.defaultOptions&&(i=this.$options.apollo=Object.assign({},e.defaultOptions,i))),K(this.$apollo,"skipAll",i.$skipAll,i.$deep),K(this.$apollo,"skipAllQueries",i.$skipAllQueries,i.$deep),K(this.$apollo,"skipAllSubscriptions",i.$skipAllSubscriptions,i.$deep),K(this.$apollo,"client",i.$client,i.$deep),K(this.$apollo,"loadingKey",i.$loadingKey,i.$deep),K(this.$apollo,"error",i.$error,i.$deep),K(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],n=this.$apollo.addSmartQuery(o,r);this.$isServer&&(r=S(r,this),!1===e.prefetch||!1===r.prefetch||!1===i.$prefetch||n.skip||this.$_apolloPromises.push(n.firstRun))}if(i.subscribe&&k.Vue.util.warn("vue-apollo -> `subscribe` option is deprecated. Use the `$subscribe` option instead."),i.$subscribe)for(var s in i.$subscribe)this.$apollo.addSmartSubscription(s,i.$subscribe[s])}}}function K(t,e,i,o){void 0!==i&&("function"==typeof i?t.defineReactiveSetter(e,i,o):t[e]=i)}function N(){this.$_apollo&&(this.$_apollo.destroy(),this.$_apollo=null)}function V(t,e){t.mixin(c({},"1"===e?{init:M}:{},{},"2"===e?{data:function(){return{$apolloData:{queries:{},loading:0,data:this.$_apolloInitData}}},beforeCreate:function(){M.call(this),function(){var i=this;this.$_apolloInitData={};var t=this.$options.apollo;if(t){var e=function(e){"$"!==e.charAt(0)&&(t[e].manual||I(i.$options.props,e)||I(i.$options.computed,e)||I(i.$options.methods,e)||Object.defineProperty(i,e,{get:function(){return i.$data.$apolloData.data[e]},set:function(t){return i.$_apolloInitData[e]=t},enumerable:!0,configurable:!0}))};for(var o in t)e(o)}}.call(this)},serverPrefetch:function(){if(this.$_apolloPromises)return Promise.all(this.$_apolloPromises)}}:{},{created:T,destroyed:N}))}var F=["$subscribe"];function H(t,e){if(!H.installed){H.installed=!0;var i=(k.Vue=t).version.substr(0,t.version.indexOf(".")),l=t.config.optionMergeStrategies.methods;t.config.optionMergeStrategies.apollo=function(t,e,i){if(!t)return e;if(!e)return t;for(var o=Object.assign({},_(t,F),t.data),r=Object.assign({},_(e,F),e.data),n={},s=0;s<F.length;s++){var a=F[s];n[a]=l(t[a],e[a])}return Object.assign(n,l(o,r))},Object.defineProperty(t.prototype,"$apollo",{get:function(){return this.$_apollo||(this.$_apollo=new R(this)),this.$_apollo}}),V(t,i),"2"===i&&(t.component("apollo-query",E),t.component("ApolloQuery",E),t.component("apollo-subscribe-to-more",x),t.component("ApolloSubscribeToMore",x),t.component("apollo-mutation",C),t.component("ApolloMutation",C))}}Q.install=H,Q.version="3.0.0-rc.6";var J=Q,G=E,B=x,W=C,U=null;return"undefined"!=typeof window?U=window.Vue:"undefined"!=typeof global&&(U=global.Vue),U&&U.use(Q),t.ApolloMutation=W,t.ApolloProvider=J,t.ApolloQuery=G,t.ApolloSubscribeToMore=B,t.default=Q,t.install=H,t}({},gql);
|