UNPKG

7.52 kBJavaScriptView Raw
1!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/core"),require("@apollo/client/core"),require("rxjs"),require("rxjs/operators")):"function"==typeof define&&define.amd?define("apollo-angular",["exports","@angular/core","@apollo/client/core","rxjs","rxjs/operators"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).ngApollo={},t.ng.core,t.core,t.rxjs,t.rxjs.operators)}(this,(function(t,e,n,r,o){"use strict";
2/*! *****************************************************************************
3 Copyright (c) Microsoft Corporation.
4
5 Permission to use, copy, modify, and/or distribute this software for any
6 purpose with or without fee is hereby granted.
7
8 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
9 REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
10 AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
11 INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
12 LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
13 OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14 PERFORMANCE OF THIS SOFTWARE.
15 ***************************************************************************** */var i=function(t,e){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};Object.create;Object.create;function s(t){return new r.Observable((function(e){return t().then((function(t){e.closed||(e.next(t),e.complete())}),(function(t){e.closed||e.error(t)})),function(){return e.unsubscribe()}}))}var u=function(){function t(t){this.zone=t,this.now=Date.now?Date.now:function(){return+new Date}}return t.prototype.schedule=function(t,e,n){return void 0===e&&(e=0),this.zone.run((function(){return r.queueScheduler.schedule(t,e,n)}))},t}();function c(t){return t[r.observable]=function(){return t},t}function a(t,e){return t.pipe(o.observeOn(new u(e)))}var p=function(){function t(t,e,n){this.obsQuery=t;var i=a(r.from(c(this.obsQuery)),e);this.valueChanges=n.useInitialLoading?i.pipe(o.startWith(Object.assign(Object.assign({},this.obsQuery.getCurrentResult()),{error:void 0,partial:void 0,stale:!0}))):i,this.queryId=this.obsQuery.queryId}return t.prototype.result=function(){return this.obsQuery.result()},t.prototype.getLastResult=function(){return this.obsQuery.getLastResult()},t.prototype.getLastError=function(){return this.obsQuery.getLastError()},t.prototype.resetLastResults=function(){return this.obsQuery.resetLastResults()},t.prototype.refetch=function(t){return this.obsQuery.refetch(t)},t.prototype.fetchMore=function(t){return this.obsQuery.fetchMore(t)},t.prototype.subscribeToMore=function(t){return this.obsQuery.subscribeToMore(t)},t.prototype.updateQuery=function(t){return this.obsQuery.updateQuery(t)},t.prototype.stopPolling=function(){return this.obsQuery.stopPolling()},t.prototype.startPolling=function(t){return this.obsQuery.startPolling(t)},t.prototype.setOptions=function(t){return this.obsQuery.setOptions(t)},t.prototype.setVariables=function(t){return this.obsQuery.setVariables(t)},t}(),l=new e.InjectionToken("APOLLO_FLAGS"),f=new e.InjectionToken("APOLLO_OPTIONS"),h=new e.InjectionToken("APOLLO_NAMED_OPTIONS"),y=function(){function t(t,e,n){this.ngZone=t,this.flags=e,this._client=n,this.useInitialLoading=function(t,e,n){return t&&void 0!==t[e]?t[e]:n}(e,"useInitialLoading",!1)}return t.prototype.watchQuery=function(t){return new p(this.ensureClient().watchQuery(Object.assign({},t)),this.ngZone,Object.assign({useInitialLoading:this.useInitialLoading},t))},t.prototype.query=function(t){var e=this;return s((function(){return e.ensureClient().query(Object.assign({},t))}))},t.prototype.mutate=function(t){var e=this;return s((function(){return e.ensureClient().mutate(Object.assign({},t))}))},t.prototype.subscribe=function(t,e){var n=r.from(c(this.ensureClient().subscribe(Object.assign({},t))));return e&&!0!==e.useZone?n:a(n,this.ngZone)},t.prototype.getClient=function(){return this.client},t.prototype.setClient=function(t){this.client=t},Object.defineProperty(t.prototype,"client",{get:function(){return this._client},set:function(t){if(this._client)throw new Error("Client has been already defined");this._client=t},enumerable:!1,configurable:!0}),t.prototype.ensureClient=function(){return this.checkInstance(),this._client},t.prototype.checkInstance=function(){if(!this._client)throw new Error("Client has not been defined yet")},t}(),b=function(t){function e(e,n,r,o){var i=t.call(this,e,o)||this;if(i._ngZone=e,i.map=new Map,n&&i.createDefault(n),r&&"object"==typeof r)for(var s in r)if(r.hasOwnProperty(s)){var u=r[s];i.createNamed(s,u)}return i}return function(t,e){function n(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}(e,t),e.prototype.create=function(t,e){d(e)?this.createDefault(t):this.createNamed(e,t)},e.prototype.default=function(){return this},e.prototype.use=function(t){return d(t)?this.default():this.map.get(t)},e.prototype.createDefault=function(t){if(this.getClient())throw new Error("Apollo has been already created.");return this.setClient(new n.ApolloClient(t))},e.prototype.createNamed=function(t,e){if(this.map.has(t))throw new Error("Client "+t+" has been already created");this.map.set(t,new y(this._ngZone,this.flags,new n.ApolloClient(e)))},e.prototype.removeClient=function(t){d(t)?this._client=void 0:this.map.delete(t)},e}(y);function d(t){return!t||"default"===t}b.ɵprov=e.ɵɵdefineInjectable({factory:function(){return new b(e.ɵɵinject(e.NgZone),e.ɵɵinject(f,8),e.ɵɵinject(h,8),e.ɵɵinject(l,8))},token:b,providedIn:"root"}),b.decorators=[{type:e.Injectable,args:[{providedIn:"root"}]}],b.ctorParameters=function(){return[{type:e.NgZone},{type:void 0,decorators:[{type:e.Optional},{type:e.Inject,args:[f]}]},{type:void 0,decorators:[{type:e.Optional},{type:e.Inject,args:[h]}]},{type:void 0,decorators:[{type:e.Optional},{type:e.Inject,args:[l]}]}]};var g=function(){function t(t){this.apollo=t,this.client="default"}return t.prototype.watch=function(t,e){return this.apollo.use(this.client).watchQuery(Object.assign(Object.assign({},e),{variables:t,query:this.document}))},t.prototype.fetch=function(t,e){return this.apollo.use(this.client).query(Object.assign(Object.assign({},e),{variables:t,query:this.document}))},t}();g.decorators=[{type:e.Injectable}],g.ctorParameters=function(){return[{type:b}]};var O=function(){function t(t){this.apollo=t,this.client="default"}return t.prototype.mutate=function(t,e){return this.apollo.use(this.client).mutate(Object.assign(Object.assign({},e),{variables:t,mutation:this.document}))},t}();O.decorators=[{type:e.Injectable}],O.ctorParameters=function(){return[{type:b}]};var j=function(){function t(t){this.apollo=t,this.client="default"}return t.prototype.subscribe=function(t,e,n){return this.apollo.use(this.client).subscribe(Object.assign(Object.assign({},e),{variables:t,query:this.document}),n)},t}();j.decorators=[{type:e.Injectable}],j.ctorParameters=function(){return[{type:b}]},Object.defineProperty(t,"gql",{enumerable:!0,get:function(){return n.gql}}),t.APOLLO_FLAGS=l,t.APOLLO_NAMED_OPTIONS=h,t.APOLLO_OPTIONS=f,t.Apollo=b,t.ApolloBase=y,t.Mutation=O,t.Query=g,t.QueryRef=p,t.Subscription=j,Object.defineProperty(t,"__esModule",{value:!0})}));
16//# sourceMappingURL=ngApollo.umd.min.js.map
\No newline at end of file