UNPKG

@vue/apollo-option

Version:

Use Apollo and GraphQL with Vue.js using the `apollo` option

2 lines (1 loc) 23.7 kB
var VueApollo=(t=>{function r(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,r=Array(e);i<e;i++)r[i]=t[i];return r}function n(t,e,i){e=u(e);var r=t,e=h()?Reflect.construct(e,i||[],u(t).constructor):e.apply(t,i);if(!e||"object"!=typeof e&&"function"!=typeof e){if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");if(void 0===(e=r))throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return e}function a(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t,e){for(var i=0;i<e.length;i++){var r=e[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,b(r.key),r)}}function e(t,e,i){return e&&o(t.prototype,e),i&&o(t,i),Object.defineProperty(t,"prototype",{writable:!1}),t}function l(t,e,i){(e=b(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i}function s(){return(s="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,i){var r=((t,e)=>{for(;!{}.hasOwnProperty.call(t,e)&&null!==(t=u(t)););return t})(t,e);if(r)return(r=Object.getOwnPropertyDescriptor(r,e)).get?r.get.call(arguments.length<3?t:i):r.value}).apply(null,arguments)}function u(t){return(u=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function i(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}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&f(t,e)}function h(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(h=function(){return!!t})()}function c(e,t){var i,r=Object.keys(e);return Object.getOwnPropertySymbols&&(i=Object.getOwnPropertySymbols(e),t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,i)),r}function p(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?c(Object(i),!0).forEach(function(t){l(e,t,i[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):c(Object(i)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))})}return e}function f(t,e){return(f=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}function v(t,e){return(t=>{if(Array.isArray(t))return t})(t)||((t,e)=>{var i=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=i){var r,o,n,s,a=[],l=!0,u=!1;try{if(n=(i=i.call(t)).next,0===e){if(Object(i)!==i)return;l=!1}else for(;!(l=(r=n.call(i)).done)&&(a.push(r.value),a.length!==e);l=!0);}catch(t){u=!0,o=t}finally{try{if(!l&&null!=i.return&&(s=i.return(),Object(s)!==s))return}finally{if(u)throw o}}return a}})(t,e)||m(t,e)||(()=>{throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")})()}function d(t,e,i,r){var o=s(u(1&r?t.prototype:t),e,i);return 2&r&&"function"==typeof o?function(t){return o.apply(i,t)}:o}function y(t){return(t=>{if(Array.isArray(t))return r(t)})(t)||(t=>{if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)})(t)||m(t)||(()=>{throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")})()}function b(t){t=((t,e)=>{if("object"!=typeof t||!t)return t;var i=t[Symbol.toPrimitive];if(void 0===i)return("string"===e?String:Number)(t);if("object"!=typeof(i=i.call(t,e||"default")))return i;throw new TypeError("@@toPrimitive must return a primitive value.")})(t,"string");return"symbol"==typeof t?t:t+""}function g(t){return(g="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 m(t,e){var i;if(t)return"string"==typeof t?r(t,e):"Map"===(i="Object"===(i={}.toString.call(t).slice(8,-1))&&t.constructor?t.constructor.name:i)||"Set"===i?Array.from(t):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?r(t,e):void 0}function k(a,l,t){var u,t=t||{},e=t.noTrailing,h=void 0!==e&&e,e=t.noLeading,c=void 0!==e&&e,e=t.debounceMode,p=void 0===e?void 0:e,f=!1,v=0;function d(){u&&clearTimeout(u)}function i(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];var r=this,o=Date.now()-v;function n(){v=Date.now(),l.apply(r,e)}function s(){u=void 0}f||(c||!p||u||n(),d(),void 0===p&&a<o?c?(v=Date.now(),h||(u=setTimeout(p?s:n,a))):n():!0!==h&&(u=setTimeout(p?s:n,void 0===p?a-o:a)))}return i.cancel=function(t){t=void 0!==(t=(t||{}).upcomingOnly)&&t,d(),f=!t},i}var $=Object.freeze({__proto__:null,debounce:function(t,e,i){return i=(i||{}).atBegin,k(t,e,{debounceMode:!1!==(void 0!==i&&i)})},throttle:k});function O(i){return function(t,e){return i(e,t)}}function w(t,e){return Object.entries(t).filter(function(t){t=v(t,1)[0];return!e.includes(t)}).reduce(function(t,e){e=v(e,2);return t[e[0]]=e[1],t},{})}function _(t){t.graphQLErrors&&t.graphQLErrors.length&&(t.gqlError=t.graphQLErrors[0])}var R=O($.throttle),S=O($.debounce),A=function(t,e){for(;"function"==typeof t;)t=t.call(e);return t},j="undefined"==typeof window,x=["variables","watch","update","result","error","loadingKey","watchLoading","skip","throttle","debounce","subscribeToMore","prefetch","manual"],T={query:"_skipAllQueries",subscription:"_skipAllSubscriptions"},P=(()=>e(function t(e,i,r){a(this,t),l(this,"type",null),l(this,"vueApolloSpecialKeys",[]),this.vm=e,this.key=i,this.initialOptions=r,this.options=Object.assign({},r),this._skip=!1,this._pollInterval=null,this._watchers=[],this._destroyed=!1,this.lastApolloOptions=null},[{key:"autostart",value:function(){var t=this;"function"==typeof this.options.skip?this._skipWatcher=this.vm.$watch(function(){return t.options.skip.call(t.vm,t.vm,t.key)},this.skipChanged.bind(this),{immediate:!0,deep:this.options.deep}):this.options.skip||this.allSkip?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:"pollInterval",get:function(){return this._pollInterval},set:function(t){this._pollInterval=t}},{key:"skip",get:function(){return this._skip},set:function(t){t||this.allSkip?this.stop():this.start(),this._skip=t}},{key:"allSkip",get:function(){return this.vm.$apollo[T[this.type]]}},{key:"refresh",value:function(){this._skip||(this.stop(),this.start())}},{key:"start",value:function(){for(var t,r=this,o=(this.starting=!0,0),n=["query","document","context"];o<n.length;o++)(()=>{var t,e,i=n[o];"function"==typeof r.initialOptions[i]&&(t=r.initialOptions[i].bind(r.vm),r.options[i]=t(),e=function(t){r._destroyed||(r.options[i]=t,r.refresh())},j||(e=r.options.throttle?R(e,r.options.throttle):e,e=r.options.debounce?S(e,r.options.debounce):e),r._watchers.push(r.vm.$watch(t,e,{deep:r.options.deep})))})();"function"==typeof this.options.variables?(t=this.executeApollo.bind(this),j||(t=this.options.throttle?R(t,this.options.throttle):t,t=this.options.debounce?S(t,this.options.debounce):t),this._watchers.push(this.vm.$watch(function(){return"function"==typeof r.options.variables?r.options.variables.call(r.vm):r.options.variables},t,{immediate:!0,deep:this.options.deep}))):this.executeApollo(this.options.variables)}},{key:"stop",value:function(){for(var t=0,e=this._watchers;t<e.length;t++)(0,e[t])();this.sub&&(this.sub.unsubscribe(),this.sub=null)}},{key:"generateApolloOptions",value:function(t){var e=w(this.options,this.vueApolloSpecialKeys);return e.variables=t,this.lastApolloOptions=e}},{key:"executeApollo",value:function(t){this.starting=!1}},{key:"nextResult",value:function(t){t=t.error;t&&_(t)}},{key:"callHandlers",value:function(t){for(var e=!1,i=arguments.length,r=new Array(1<i?i-1:0),o=1;o<i;o++)r[o-1]=arguments[o];for(var n=0;n<t.length;n++){var s=t[n];if(s){e=!0,s=s.apply(this.vm,r);if(void 0!==s&&!s)break}}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){_(t);var e=this.errorHandler(t,this.vm,this.key,this.type,this.lastApolloOptions);if(!e)if(t.graphQLErrors&&0!==t.graphQLErrors.length){console.error("GraphQL execution errors for ".concat(this.type," '").concat(this.key,"'"));for(var i=0,r=t.graphQLErrors;i<r.length;i++){var o=r[i];console.error(o)}}else t.networkError?console.error("Error sending the ".concat(this.type," '").concat(this.key,"'"),t.networkError):(console.error("[vue-apollo] An error has occurred for ".concat(this.type," '").concat(this.key,"'")),Array.isArray(t)?(e=console).error.apply(e,y(t)):console.error(t))}},{key:"destroy",value:function(){this._destroyed||(this._destroyed=!0,this.stop(),this._skipWatcher&&this._skipWatcher())}}]))(),M=(()=>{function s(t,e,i){var r,o=!(3<arguments.length&&void 0!==arguments[3])||arguments[3];return a(this,s),t.$data.$apolloData&&!t.$data.$apolloData.queries[e]&&(t.$data.$apolloData.queries[e]={loading:!1}),l(r=n(this,s,[t,e,i]),"type","query"),l(r,"vueApolloSpecialKeys",x),l(r,"_loading",!1),l(r,"_linkedSubscriptions",[]),j&&(r.firstRun=new Promise(function(t,e){r._firstRunResolve=t,r._firstRunReject=e})),j&&(r.options.fetchPolicy="network-only"),i.manual||(r.hasDataField=Object.prototype.hasOwnProperty.call(r.vm.$data,e),r.hasDataField?Object.defineProperty(r.vm.$data.$apolloData.data,e,{get:function(){return r.vm.$data[e]},enumerable:!0,configurable:!0}):Object.defineProperty(r.vm.$data,e,{get:function(){return r.vm.$data.$apolloData.data[e]},enumerable:!0,configurable:!0})),o&&r.autostart(),r}return i(s,P),e(s,[{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:"stop",value:function(){d(s,"stop",this,3)([]),this.loadingDone(),this.observer&&(this.observer.stopPolling(),this.observer=null)}},{key:"generateApolloOptions",value:function(t){t=d(s,"generateApolloOptions",this,3)([t]);return this.vm.$isServer&&delete t.pollInterval,t}},{key:"executeApollo",value:function(t){if(!this._destroyed){var e=JSON.stringify(t);if(this.sub){if(e===this.previousVariablesJson)return;this.sub.unsubscribe();for(var i=0,r=this._linkedSubscriptions;i<r.length;i++)r[i].stop()}this.previousVariablesJson=e,this.observer=this.vm.$apollo.watchQuery(this.generateApolloOptions(t)),this.startQuerySubscription(),("no-cache"!==this.options.fetchPolicy||this.options.notifyOnNetworkStatusChange)&&(e=this.retrieveCurrentResult(),this.options.notifyOnNetworkStatusChange||this.observer.getCurrentResult&&!e.loading)&&this.nextResult(e),d(s,"executeApollo",this,3)([t]);for(var o=0,n=this._linkedSubscriptions;o<n.length;o++)n[o].start()}}},{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:"retrieveCurrentResult",value:function(){var t=0<arguments.length&&void 0!==arguments[0]&&arguments[0],e=this.observer.getCurrentResult?this.observer.getCurrentResult():this.observer.currentResult();return(t||e.loading)&&(this.loading||this.applyLoadingModifier(1),this.loading=!0),e}},{key:"nextResult",value:function(t){d(s,"nextResult",this,3)([t]);var e=t.data,i=t.loading,r=t.error,o=t.errors,n=o&&o.length;(r||n)&&this.firstRunReject(r),i||this.loadingDone(),!r&&n&&(i=new Error("GraphQL error: ".concat(o.map(function(t){return t.message}).join(" | "))),Object.assign(i,{graphQLErrors:o,networkError:null}),d(s,"catchError",this,3)([i])),"none"===this.observer.options.errorPolicy&&(r||n)||(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.hasDataField?this.vm.$data:this.vm.$data.$apolloData.data)[this.key]=t}},{key:"catchError",value:function(t){d(s,"catchError",this,3)([t]),this.firstRunReject(t),this.loadingDone(t),this.nextResult(this.observer.getCurrentResult?this.observer.getCurrentResult():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:"loadingKey",get:function(){return this.options.loadingKey||this.vm.$apollo.loadingKey}},{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(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null;this.loading&&this.applyLoadingModifier(-1),this.loading=!1,t||this.firstRunResolve()}},{key:"fetchMore",value:function(){var t,e=this;if(this.observer)return this.retrieveCurrentResult(!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)return t=this.observer.refetch(t).then(function(t){return t.loading||e.loadingDone(),t}),this.retrieveCurrentResult(),t}},{key:"setVariables",value:function(t,e){if(this.options.variables=t,this.observer)return t=this.observer.setVariables(t,e),this.retrieveCurrentResult(),t}},{key:"setOptions",value:function(t){if(Object.assign(this.options,t),this.observer)return t=this.observer.setOptions(t),this.retrieveCurrentResult(),t}},{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(s,"destroy",this,3)([]),this.loading&&this.watchLoading(!1,-1),this.loading=!1}}])})(),I=(()=>{function o(t,e,i){var r=!(3<arguments.length&&void 0!==arguments[3])||arguments[3];return a(this,o),l(t=n(this,o,[t,e,i]),"type","subscription"),l(t,"vueApolloSpecialKeys",["variables","result","error","throttle","debounce","linkedQuery"]),t.attempts=0,r&&t.autostart(),t}return i(o,P),e(o,[{key:"generateApolloOptions",value:function(t){t=d(o,"generateApolloOptions",this,3)([t]);return t.onError=this.catchError.bind(this),t}},{key:"executeApollo",value:function(t){if(!this._destroyed){var e=JSON.stringify(t);if(this.sub){if(e===this.previousVariablesJson)return;this.sub.unsubscribe()}this.previousVariablesJson=e;var i,r,e=this.generateApolloOptions(t);"function"==typeof e.updateQuery&&(e.updateQuery=e.updateQuery.bind(this.vm)),this.options.linkedQuery?("function"==typeof this.options.result&&(i=this.options.result.bind(this.vm),r=e.updateQuery&&e.updateQuery.bind(this.vm),e.updateQuery=function(){return i.apply(void 0,arguments),r&&r.apply(void 0,arguments)}),this.sub=this.options.linkedQuery.subscribeToMore(e)):(this.observer=this.vm.$apollo.subscribe(e),this.sub=this.observer.subscribe({next:this.nextResult.bind(this),error:this.catchError.bind(this)})),d(o,"executeApollo",this,3)([t])}}},{key:"nextResult",value:function(t){d(o,"nextResult",this,3)([t]),this.attempts=0,"function"==typeof this.options.result&&this.options.result.call(this.vm,t,this.key)}},{key:"catchError",value:function(t){d(o,"catchError",this,3)([t]),this.skip||5<=this.attempts||(this.stop(),this.retryTimeout=setTimeout(this.start.bind(this),500*Math.pow(2,this.attempts)),this.attempts++)}},{key:"stop",value:function(){d(o,"stop",this,3)([]),clearTimeout(this.retryTimeout)}}])})(),K=(()=>e(function t(e,i){a(this,t),this._apolloSubscriptions=[],this._watchers=[],this.vm=e,this.provider=i,this.queries={},this.subscriptions={},this.client=void 0,this.loadingKey=void 0,this.error=void 0},[{key:"getClient",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null;if(!t||!t.client){if("object"===g(this.client))return this.client;if(this.client){if(this.provider.clients){var e=this.provider.clients[this.client];if(e)return e;throw new Error("[vue-apollo] Missing client '".concat(this.client,"' in 'apolloProvider'"))}throw new Error("[vue-apollo] Missing 'clients' options in 'apolloProvider'")}return this.provider.defaultClient}e=this.provider.clients[t.client];if(e)return e;throw new Error("[vue-apollo] Missing client '".concat(t.client,"' in 'apolloProvider'"))}},{key:"query",value:function(t){return this.getClient(t).query(t)}},{key:"watchQuery",value:function(t){var e=this,t=this.getClient(t).watchQuery(t),i=t.subscribe.bind(t);return t.subscribe=function(t){t=i(t);return e._apolloSubscriptions.push(t),t},t}},{key:"mutate",value:function(t){return this.getClient(t).mutate(t)}},{key:"subscribe",value:function(t){var e,i=this;if(!j)return t=this.getClient(t).subscribe(t),e=t.subscribe.bind(t),t.subscribe=function(t){t=e(t);return i._apolloSubscriptions.push(t),t},t}},{key:"loading",get:function(){return 0!==this.vm.$data.$apolloData.loading}},{key:"data",get:function(){return this.vm.$data.$apolloData.data}},{key:"addSmartQuery",value:function(i,t){var e,r=this,o=A(t,this.vm),t=(o.query||(o={query:o}),this.vm.$options.apollo),n=this.provider.defaultOptions;if(n&&n.$query&&(e=n.$query),e=t&&t.$query?p(p({},e||{}),t.$query):e)for(var s in e)void 0===o[s]&&(o[s]=e[s]);var a=this.queries[i]=new M(this.vm,i,o,!1);return j&&!1===o.prefetch||a.autostart(),j||(n=o.subscribeToMore)&&(Array.isArray(n)?n.forEach(function(t,e){r.addSmartSubscription("".concat(i).concat(e),p(p({},t),{},{linkedQuery:a}))}):this.addSmartSubscription(i,p(p({},n),{},{linkedQuery:a}))),a}},{key:"addSmartSubscription",value:function(e,t){var i,r;if(!j)return t=A(t,this.vm),(i=this.subscriptions[e]=new I(this.vm,e,t,!1)).autostart(),t.linkedQuery&&(-1!==(r=t.linkedQuery._linkedSubscriptions.findIndex(function(t){return t.key===e}))?t.linkedQuery._linkedSubscriptions[r]=i:t.linkedQuery._linkedSubscriptions.push(i)),i}},{key:"defineReactiveSetter",value:function(e,t,i){var r=this;this._watchers.push(this.vm.$watch(t,function(t){r[e]=t},{immediate:!0,deep:i}))}},{key:"skipAllQueries",set:function(t){for(var e in this._skipAllQueries=t,this.queries)this.queries[e].skip=t}},{key:"skipAllSubscriptions",set:function(t){for(var e in this._skipAllSubscriptions=t,this.subscriptions)this.subscriptions[e].skip=t}},{key:"skipAll",set:function(t){this.skipAllQueries=t,this.skipAllSubscriptions=t}},{key:"destroy",value:function(){for(var t,e,i=0,r=this._watchers;i<r.length;i++)(0,r[i])();for(t in this.queries)this.queries[t].destroy();for(e in this.subscriptions)this.subscriptions[e].destroy();this._apolloSubscriptions.forEach(function(t){t.unsubscribe()}),this._apolloSubscriptions=null,this.vm=null}}]))();function E(t,e){return void 0!==t&&Object.prototype.hasOwnProperty.call(t,e)}function V(){var t=this,e=this.$apolloProvider;if(!this._apolloLaunched&&e){this._apolloLaunched=!0;var i,r=this.$options.apollo;if(r){for(var o in this.$_apolloPromises=[],r.$init||(r.$init=!0,e.defaultOptions&&(r=this.$options.apollo=Object.assign({},e.defaultOptions,r))),D(this.$apollo,"skipAll",r.$skipAll,r.$deep),D(this.$apollo,"skipAllQueries",r.$skipAllQueries,r.$deep),D(this.$apollo,"skipAllSubscriptions",r.$skipAllSubscriptions,r.$deep),D(this.$apollo,"client",r.$client,r.$deep),D(this.$apollo,"loadingKey",r.$loadingKey,r.$deep),D(this.$apollo,"error",r.$error,r.$deep),D(this.$apollo,"watchLoading",r.$watchLoading,r.$deep),Object.defineProperty(this,"$apolloData",{get:function(){return t.$data.$apolloData},enumerable:!0,configurable:!0}),r)"$"!==o.charAt(0)&&(i=r[o],o=this.$apollo.addSmartQuery(o,i),j)&&(i=A(i,this),!1===e.prefetch||!1===i.prefetch||!1===r.$prefetch||o.skip||this.$_apolloPromises.push(o.firstRun));if(r.subscribe&&console.warn("vue-apollo -> `subscribe` option is deprecated. Use the `$subscribe` option instead."),r.$subscribe)for(var n in r.$subscribe)this.$apollo.addSmartSubscription(n,r.$subscribe[n])}}}function D(t,e,i,r){void 0!==i&&("function"==typeof i?t.defineReactiveSetter(e,i,r):t[e]=i)}function Q(){this.$apollo&&(this.$apollo.destroy(),this.$apollo=null)}var L=["$subscribe"],C=(()=>e(function t(e){if(a(this,t),!e)throw new Error("Options argument required");this.clients=e.clients||{},e.defaultClient&&(this.clients.defaultClient=this.defaultClient=e.defaultClient),this.defaultOptions=e.defaultOptions,this.watchLoading=e.watchLoading,this.errorHandler=e.errorHandler,this.prefetch=e.prefetch},[{key:"install",value:function(t){var r;t.config.optionMergeStrategies.apollo=function(t,e,i){if(!t)return e;if(!e)return t;for(var r=Object.assign({},w(t,L),t.data),o=Object.assign({},w(e,L),e.data),n={},s=0;s<L.length;s++){var a=L[s];n[a]=q(t[a],e[a])}return Object.assign(n,q(r,o))},t.config.globalProperties.$apolloProvider=this,r=this,t.mixin({data:function(){var t={$apolloData:{queries:{},loading:0,data:{}}},e=this.$options.apollo;if(e)for(var i in e)"$"===i.charAt(0)||e[i].manual||E(this.$options.props,i)||E(this.$options.computed,i)||E(this.$options.methods,i)||(t[i]=null);return t},beforeCreate:function(){var e,i=this;this.$apollo=new K(this,r),j&&(e=this.$options.ssrRender)&&!e.__IS_VUE_APOLLO_WRAPPED&&(this.$options.ssrRender=function(t){t=e.call(i,t);return Q.call(i),t},this.$options.ssrRender.__IS_VUE_APOLLO_WRAPPED=!0)},serverPrefetch:function(){var e=this;if(this.$_apolloPromises)return Promise.all(this.$_apolloPromises).then(function(){var t={vm:e,provider:e.$apollo.provider,loading:!1,queries:{},subscriptions:{}};Q.call(e),e.$apollo=t}).catch(function(t){return Q.call(e),Promise.reject(t)})},created:V,unmounted:Q})}}]))();function q(t,e){return t?Object.assign(Object.assign(Object.create(null),t),e):e}return t.ApolloProvider=C,t.createApolloProvider=function(t){return new C(t)},t})({});