Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

apollo-client

Package Overview
Dependencies
Maintainers
8
Versions
309
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

apollo-client - npm Package Compare versions

Comparing version 2.6.0-beta.3 to 2.6.0-beta.4

2

bundle.cjs.min.js

@@ -1,1 +0,1 @@

"use strict";function t(t){return t&&"object"==typeof t&&"default"in t?t.default:t}Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),r=require("apollo-utilities"),o=require("apollo-link"),n=t(require("symbol-observable")),s=require("ts-invariant"),i=require("graphql/language/visitor");function a(t){return t<7}!function(t){t[t.loading=1]="loading",t[t.setVariables=2]="setVariables",t[t.fetchMore=3]="fetchMore",t[t.refetch=4]="refetch",t[t.poll=6]="poll",t[t.ready=7]="ready",t[t.error=8]="error"}(exports.NetworkStatus||(exports.NetworkStatus={}));var u=function(t){function r(){return null!==t&&t.apply(this,arguments)||this}return e.__extends(r,t),r.prototype[n]=function(){return this},r.prototype["@@observable"]=function(){return this},r}(o.Observable);function c(t){return t.hasOwnProperty("graphQLErrors")}var l=function(t){var e="";return Array.isArray(t.graphQLErrors)&&0!==t.graphQLErrors.length&&t.graphQLErrors.forEach(function(t){var r=t?t.message:"Error message not found.";e+="GraphQL error: "+r+"\n"}),t.networkError&&(e+="Network error: "+t.networkError.message+"\n"),e=e.replace(/\n$/,"")},h=function(t){function r(e){var o=e.graphQLErrors,n=e.networkError,s=e.errorMessage,i=e.extraInfo,a=t.call(this,s)||this;return a.graphQLErrors=o||[],a.networkError=n||null,a.message=s||l(a),a.extraInfo=i,a.__proto__=r.prototype,a}return e.__extends(r,t),r}(Error);!function(t){t[t.normal=1]="normal",t[t.refetch=2]="refetch",t[t.poll=3]="poll"}(exports.FetchType||(exports.FetchType={}));var p=function(t,e){return void 0===e&&(e="none"),t&&(t.graphQLErrors&&t.graphQLErrors.length>0&&"none"===e||t.networkError)},f=function(t){function o(e){var o=e.queryManager,n=e.options,s=e.shouldSubscribe,i=void 0===s||s,a=t.call(this,function(t){return a.onSubscribe(t)})||this;a.observers=new Set,a.subscriptions=new Set,a.isTornDown=!1,a.options=n,a.variables=n.variables||{},a.queryId=o.generateQueryId(),a.shouldSubscribe=i;var u=r.getOperationDefinition(n.query);return a.queryName=u&&u.name&&u.name.value,a.queryManager=o,a}return e.__extends(o,t),o.prototype.result=function(){var t=this;return new Promise(function(e,r){var o={next:function(r){e(r),t.observers.delete(o),t.observers.size||t.queryManager.removeQuery(t.queryId),setTimeout(function(){n.unsubscribe()},0)},error:r},n=t.subscribe(o)})},o.prototype.currentResult=function(){var t=this.getCurrentResult();return void 0===t.data&&(t.data={}),t},o.prototype.getCurrentResult=function(){if(this.isTornDown){var t=this.lastResult;return{data:!this.lastError&&t&&t.data||void 0,error:this.lastError,loading:!1,networkStatus:exports.NetworkStatus.error}}var r,o=this.queryManager.getCurrentQueryResult(this),n=o.data,s=o.partial,i=this.queryManager.queryStore.get(this.queryId);if(i){var u=i.networkStatus;if(p(i,this.options.errorPolicy))return{data:void 0,loading:!1,networkStatus:u,error:new h({graphQLErrors:i.graphQLErrors,networkError:i.networkError})};i.variables&&(this.options.variables=e.__assign({},this.options.variables,i.variables),this.variables=this.options.variables),r={data:n,loading:a(u),networkStatus:u},i.graphQLErrors&&"all"===this.options.errorPolicy&&(r.errors=i.graphQLErrors)}else{var c=this.options.fetchPolicy,l="network-only"===c||s&&"cache-only"!==c;r={data:n,loading:l,networkStatus:l?exports.NetworkStatus.loading:exports.NetworkStatus.ready}}return s||this.updateLastResult(e.__assign({},r,{stale:!1})),e.__assign({},r,{partial:s})},o.prototype.isDifferentFromLastResult=function(t){var e=this.lastResultSnapshot;return!(e&&t&&e.networkStatus===t.networkStatus&&e.stale===t.stale&&r.isEqual(e.data,t.data))},o.prototype.getLastResult=function(){return this.lastResult},o.prototype.getLastError=function(){return this.lastError},o.prototype.resetLastResults=function(){delete this.lastResult,delete this.lastResultSnapshot,delete this.lastError,this.isTornDown=!1},o.prototype.refetch=function(t){var o=this.options.fetchPolicy;return"cache-only"===o?Promise.reject(new s.InvariantError(3)):("no-cache"!==o&&(o="network-only"),r.isEqual(this.variables,t)||(this.variables=e.__assign({},this.variables,t)),r.isEqual(this.options.variables,this.variables)||(this.options.variables=e.__assign({},this.options.variables,this.variables)),this.queryManager.fetchQuery(this.queryId,e.__assign({},this.options,{fetchPolicy:o}),exports.FetchType.refetch))},o.prototype.fetchMore=function(t){var r=this;s.invariant(t.updateQuery,4);var o=e.__assign({},t.query?t:e.__assign({},this.options,t,{variables:e.__assign({},this.variables,t.variables)}),{fetchPolicy:"network-only"});return this.queryManager.fetchQuery(this.queryManager.generateQueryId(),o,exports.FetchType.normal,this.queryId).then(function(e){return r.updateQuery(function(r){return t.updateQuery(r,{fetchMoreResult:e.data,variables:o.variables})}),e})},o.prototype.subscribeToMore=function(t){var e=this,r=this.queryManager.startGraphQLSubscription({query:t.document,variables:t.variables}).subscribe({next:function(r){t.updateQuery&&e.updateQuery(function(e,o){var n=o.variables;return t.updateQuery(e,{subscriptionData:r,variables:n})})},error:function(e){t.onError&&t.onError(e)}});return this.subscriptions.add(r),function(){e.subscriptions.delete(r)&&r.unsubscribe()}},o.prototype.setOptions=function(t){var r=this.options.fetchPolicy;this.options=e.__assign({},this.options,t),t.pollInterval?this.startPolling(t.pollInterval):0===t.pollInterval&&this.stopPolling();var o=t.fetchPolicy;return this.setVariables(this.options.variables,r!==o&&("cache-only"===r||"standby"===r||"network-only"===o),t.fetchResults)},o.prototype.setVariables=function(t,e,o){return void 0===e&&(e=!1),void 0===o&&(o=!0),this.isTornDown=!1,t=t||this.variables,!e&&r.isEqual(t,this.variables)?this.observers.size&&o?this.result():Promise.resolve():(this.variables=this.options.variables=t,this.observers.size?this.queryManager.fetchQuery(this.queryId,this.options):Promise.resolve())},o.prototype.updateQuery=function(t){var e=this.queryManager,o=e.getQueryWithPreviousResult(this.queryId),n=o.previousResult,s=o.variables,i=o.document,a=r.tryFunctionOrLogError(function(){return t(n,{variables:s})});a&&(e.dataStore.markUpdateQueryResult(i,s,a),e.broadcastQueries())},o.prototype.stopPolling=function(){this.queryManager.stopPollingQuery(this.queryId),this.options.pollInterval=void 0},o.prototype.startPolling=function(t){d(this),this.options.pollInterval=t,this.queryManager.startPollingQuery(this.options,this.queryId)},o.prototype.updateLastResult=function(t){var e=this.lastResult;return this.lastResult=t,this.lastResultSnapshot=this.queryManager.assumeImmutableResults?t:r.cloneDeep(t),e},o.prototype.onSubscribe=function(t){var e=this,r=!this.observers.size;return this.observers.add(t),t.next&&this.lastResult&&t.next(this.lastResult),t.error&&this.lastError&&t.error(this.lastError),r&&this.setUpQuery(),function(){e.observers.delete(t)&&!e.observers.size&&e.tearDownQuery()}},o.prototype.setUpQuery=function(){var t=this,e=this.queryManager,o=this.queryId;this.shouldSubscribe&&e.addObservableQuery(o,this),this.options.pollInterval&&(d(this),e.startPollingQuery(this.options,o));var n=function(e){y(t.observers,"error",t.lastError=e)};e.observeQuery(o,this.options,{next:function(o){if(t.lastError||t.isDifferentFromLastResult(o)){var n=t.updateLastResult(o),s=t.options,i=s.query,a=s.variables,u=s.fetchPolicy;e.transform(i).hasClientExports?e.getLocalState().addExportedVariables(i,a).then(function(s){var a=t.variables;t.variables=t.options.variables=s,!o.loading&&n&&"cache-only"!==u&&e.transform(i).serverQuery&&!r.isEqual(a,s)?t.refetch():y(t.observers,"next",o)}):y(t.observers,"next",o)}},error:n}).catch(n)},o.prototype.tearDownQuery=function(){var t=this.queryManager;this.isTornDown=!0,t.stopPollingQuery(this.queryId),this.subscriptions.forEach(function(t){return t.unsubscribe()}),this.subscriptions.clear(),t.removeObservableQuery(this.queryId),t.stopQuery(this.queryId),this.observers.clear()},o}(u);function y(t,e,r){var o=[];t.forEach(function(t){return t[e]&&o.push(t)}),o.forEach(function(t){return t[e](r)})}function d(t){var e=t.options.fetchPolicy;s.invariant("cache-first"!==e&&"cache-only"!==e,5)}var v=function(){function t(){this.store={}}return t.prototype.getStore=function(){return this.store},t.prototype.get=function(t){return this.store[t]},t.prototype.initMutation=function(t,e,r){this.store[t]={mutation:e,variables:r||{},loading:!0,error:null}},t.prototype.markMutationError=function(t,e){var r=this.store[t];r&&(r.loading=!1,r.error=e)},t.prototype.markMutationResult=function(t){var e=this.store[t];e&&(e.loading=!1,e.error=null)},t.prototype.reset=function(){this.store={}},t}(),b=function(){function t(){this.store={}}return t.prototype.getStore=function(){return this.store},t.prototype.get=function(t){return this.store[t]},t.prototype.initQuery=function(t){var e=this.store[t.queryId];if(e&&e.document!==t.document&&!r.isEqual(e.document,t.document))throw new s.InvariantError(19);var o,n=!1,i=null;t.storePreviousVariables&&e&&e.networkStatus!==exports.NetworkStatus.loading&&(r.isEqual(e.variables,t.variables)||(n=!0,i=e.variables)),o=n?exports.NetworkStatus.setVariables:t.isPoll?exports.NetworkStatus.poll:t.isRefetch?exports.NetworkStatus.refetch:exports.NetworkStatus.loading;var a=[];e&&e.graphQLErrors&&(a=e.graphQLErrors),this.store[t.queryId]={document:t.document,variables:t.variables,previousVariables:i,networkError:null,graphQLErrors:a,networkStatus:o,metadata:t.metadata},"string"==typeof t.fetchMoreForQueryId&&this.store[t.fetchMoreForQueryId]&&(this.store[t.fetchMoreForQueryId].networkStatus=exports.NetworkStatus.fetchMore)},t.prototype.markQueryResult=function(t,e,r){this.store&&this.store[t]&&(this.store[t].networkError=null,this.store[t].graphQLErrors=e.errors&&e.errors.length?e.errors:[],this.store[t].previousVariables=null,this.store[t].networkStatus=exports.NetworkStatus.ready,"string"==typeof r&&this.store[r]&&(this.store[r].networkStatus=exports.NetworkStatus.ready))},t.prototype.markQueryError=function(t,e,r){this.store&&this.store[t]&&(this.store[t].networkError=e,this.store[t].networkStatus=exports.NetworkStatus.error,"string"==typeof r&&this.markQueryResultClient(r,!0))},t.prototype.markQueryResultClient=function(t,e){this.store&&this.store[t]&&(this.store[t].networkError=null,this.store[t].previousVariables=null,this.store[t].networkStatus=e?exports.NetworkStatus.ready:exports.NetworkStatus.loading)},t.prototype.stopQuery=function(t){delete this.store[t]},t.prototype.reset=function(t){var r=this;this.store=Object.keys(this.store).filter(function(e){return t.indexOf(e)>-1}).reduce(function(t,o){return t[o]=e.__assign({},r.store[o],{networkStatus:exports.NetworkStatus.loading}),t},{})},t}();function m(t){return t.charAt(0).toUpperCase()+t.slice(1)}var g=function(){function t(t){var e=t.cache,r=t.client,o=t.resolvers,n=t.fragmentMatcher;this.cache=e,r&&(this.client=r),o&&this.addResolvers(o),n&&this.setFragmentMatcher(n)}return t.prototype.addResolvers=function(t){var e=this;this.resolvers=this.resolvers||{},Array.isArray(t)?t.forEach(function(t){e.resolvers=r.mergeDeep(e.resolvers,t)}):this.resolvers=r.mergeDeep(this.resolvers,t)},t.prototype.setResolvers=function(t){this.resolvers={},this.addResolvers(t)},t.prototype.getResolvers=function(){return this.resolvers||{}},t.prototype.runResolvers=function(t){var r=t.document,o=t.remoteResult,n=t.context,s=t.variables,i=t.onlyRunForcedResolvers,a=void 0!==i&&i;return e.__awaiter(this,void 0,void 0,function(){return e.__generator(this,function(t){return r?[2,this.resolveDocument(r,o.data,n,s,this.fragmentMatcher,a).then(function(t){return e.__assign({},o,{data:t.result})})]:[2,o]})})},t.prototype.setFragmentMatcher=function(t){this.fragmentMatcher=t},t.prototype.getFragmentMatcher=function(){return this.fragmentMatcher},t.prototype.clientQuery=function(t){return r.hasDirectives(["client"],t)&&this.resolvers?t:null},t.prototype.serverQuery=function(t){return this.resolvers?r.removeClientSetsFromDocument(t):t},t.prototype.prepareContext=function(t){void 0===t&&(t={});var r=this.cache;return e.__assign({},t,{cache:r,getCacheKey:function(t){if(r.config)return r.config.dataIdFromObject(t);s.invariant(!1,17)}})},t.prototype.addExportedVariables=function(t,r,o){return void 0===r&&(r={}),void 0===o&&(o={}),e.__awaiter(this,void 0,void 0,function(){return e.__generator(this,function(n){return t?[2,this.resolveDocument(t,this.buildRootValueFromCache(t,r)||{},this.prepareContext(o),r).then(function(t){return e.__assign({},r,t.exportedVariables)})]:[2,e.__assign({},r)]})})},t.prototype.shouldForceResolvers=function(t){var e=!1;return i.visit(t,{Directive:{enter:function(t){if("client"===t.name.value&&t.arguments&&(e=t.arguments.some(function(t){return"always"===t.name.value&&"BooleanValue"===t.value.kind&&!0===t.value.value})))return i.BREAK}}}),e},t.prototype.shouldForceResolver=function(t){return this.shouldForceResolvers(t)},t.prototype.buildRootValueFromCache=function(t,e){return this.cache.diff({query:r.buildQueryFromSelectionSet(t),variables:e,optimistic:!1}).result},t.prototype.resolveDocument=function(t,o,n,s,i,a){return void 0===n&&(n={}),void 0===s&&(s={}),void 0===i&&(i=function(){return!0}),void 0===a&&(a=!1),e.__awaiter(this,void 0,void 0,function(){var u,c,l,h,p,f,y,d,v;return e.__generator(this,function(b){return u=r.getMainDefinition(t),c=r.getFragmentDefinitions(t),l=r.createFragmentMap(c),h=u.operation,p=h?m(h):"Query",y=(f=this).cache,d=f.client,v={fragmentMap:l,context:e.__assign({},n,{cache:y,client:d}),variables:s,fragmentMatcher:i,defaultOperationType:p,exportedVariables:{},onlyRunForcedResolvers:a},[2,this.resolveSelectionSet(u.selectionSet,o,v).then(function(t){return{result:t,exportedVariables:v.exportedVariables}})]})})},t.prototype.resolveSelectionSet=function(t,o,n){return e.__awaiter(this,void 0,void 0,function(){var i,a,u,c,l,h=this;return e.__generator(this,function(p){return i=n.fragmentMap,a=n.context,u=n.variables,c=[o],l=function(t){return e.__awaiter(h,void 0,void 0,function(){var l,h;return e.__generator(this,function(e){return r.shouldInclude(t,u)?r.isField(t)?[2,this.resolveField(t,o,n).then(function(e){var o;void 0!==e&&c.push(((o={})[r.resultKeyNameFromField(t)]=e,o))})]:(r.isInlineFragment(t)?l=t:(l=i[t.name.value],s.invariant(l,18)),l&&l.typeCondition&&(h=l.typeCondition.name.value,n.fragmentMatcher(o,h,a))?[2,this.resolveSelectionSet(l.selectionSet,o,n).then(function(t){c.push(t)})]:[2]):[2]})})},[2,Promise.all(t.selections.map(l)).then(function(){return r.mergeDeepArray(c)})]})})},t.prototype.resolveField=function(t,o,n){return e.__awaiter(this,void 0,void 0,function(){var s,i,a,u,c,l,h,p,f,y=this;return e.__generator(this,function(e){return s=n.variables,i=t.name.value,a=r.resultKeyNameFromField(t),u=i!==a,c=o[a]||o[i],l=Promise.resolve(c),n.onlyRunForcedResolvers&&!this.shouldForceResolver(t)||(h=o.__typename||n.defaultOperationType,(p=this.resolvers&&this.resolvers[h])&&(f=p[u?i:a])&&(l=Promise.resolve(f(o,r.argumentsObjectFromField(t,s),n.context,{field:t})))),[2,l.then(function(e){return void 0===e&&(e=c),t.directives&&t.directives.forEach(function(t){"export"===t.name.value&&t.arguments&&t.arguments.forEach(function(t){"as"===t.name.value&&"StringValue"===t.value.kind&&(n.exportedVariables[t.value.value]=e)})}),t.selectionSet?null==e?e:Array.isArray(e)?y.resolveSubSelectedArray(t,e,n):t.selectionSet?y.resolveSelectionSet(t.selectionSet,e,n):void 0:e})]})})},t.prototype.resolveSubSelectedArray=function(t,e,r){var o=this;return Promise.all(e.map(function(e){return null===e?null:Array.isArray(e)?o.resolveSubSelectedArray(t,e,r):t.selectionSet?o.resolveSelectionSet(t.selectionSet,e,r):void 0}))},t}();function Q(t){var e=new Set,r=null;return new u(function(o){return e.add(o),r=r||t.subscribe({next:function(t){e.forEach(function(e){return e.next&&e.next(t)})},error:function(t){e.forEach(function(e){return e.error&&e.error(t)})},complete:function(){e.forEach(function(t){return t.complete&&t.complete()})}}),function(){e.delete(o)&&!e.size&&r&&(r.unsubscribe(),r=null)}})}function w(t,e){return new u(function(r){var o=r.next,n=r.error,s=r.complete,i=0,a=!1,u={next:function(t){++i,new Promise(function(r){r(e(t))}).then(function(t){--i,o&&o.call(r,t),a&&u.complete()},function(t){--i,n&&n.call(r,t)})},error:function(t){n&&n.call(r,t)},complete:function(){a=!0,i||s&&s.call(r)}},c=t.subscribe(u);return function(){return c.unsubscribe()}})}var S=Object.prototype.hasOwnProperty,k=function(){function t(t){var e=t.link,o=t.queryDeduplication,n=void 0!==o&&o,s=t.store,i=t.onBroadcast,a=void 0===i?function(){}:i,u=t.ssrMode,c=void 0!==u&&u,l=t.clientAwareness,h=void 0===l?{}:l,p=t.localState,f=t.assumeImmutableResults;this.mutationStore=new v,this.queryStore=new b,this.clientAwareness={},this.idCounter=1,this.queries=new Map,this.fetchQueryRejectFns=new Map,this.transformCache=new(r.canUseWeakMap?WeakMap:Map),this.inFlightLinkObservables=new Map,this.pollingInfoByQueryId=new Map,this.nextPoll=null,this.link=e,this.queryDeduplication=n,this.dataStore=s,this.onBroadcast=a,this.clientAwareness=h,this.localState=p||new g({cache:s.getCache()}),this.ssrMode=c,this.assumeImmutableResults=!!f}return t.prototype.stop=function(){var t=this;this.queries.forEach(function(e,r){t.stopQueryNoBroadcast(r)}),this.fetchQueryRejectFns.forEach(function(t){t(new s.InvariantError(6))})},t.prototype.mutate=function(t){var o=t.mutation,n=t.variables,i=t.optimisticResponse,a=t.updateQueries,u=t.refetchQueries,c=void 0===u?[]:u,l=t.awaitRefetchQueries,p=void 0!==l&&l,f=t.update,y=t.errorPolicy,d=void 0===y?"none":y,v=t.fetchPolicy,b=t.context,m=void 0===b?{}:b;return e.__awaiter(this,void 0,void 0,function(){var t,u,l,y=this;return e.__generator(this,function(b){switch(b.label){case 0:return s.invariant(o,7),s.invariant(!v||"no-cache"===v,8),t=this.generateQueryId(),o=this.transform(o).document,this.setQuery(t,function(){return{document:o}}),n=this.getVariables(o,n),this.transform(o).hasClientExports?[4,this.localState.addExportedVariables(o,n,m)]:[3,2];case 1:n=b.sent(),b.label=2;case 2:return u=function(){var t={};return a&&y.queries.forEach(function(e,r){var o=e.observableQuery;if(o){var n=o.queryName;n&&S.call(a,n)&&(t[r]={updater:a[n],query:y.queryStore.get(r)})}}),t},this.mutationStore.initMutation(t,o,n),this.dataStore.markMutationInit({mutationId:t,document:o,variables:n,updateQueries:u(),update:f,optimisticResponse:i}),this.broadcastQueries(),l=this,[2,new Promise(function(s,a){var y,b;l.getObservableFromLink(o,e.__assign({},m,{optimisticResponse:i}),n,!1).subscribe({next:function(e){r.graphQLResultHasError(e)&&"none"===d?b=new h({graphQLErrors:e.errors}):(l.mutationStore.markMutationResult(t),"no-cache"!==v&&l.dataStore.markMutationResult({mutationId:t,result:e,document:o,variables:n,updateQueries:u(),update:f}),y=e)},error:function(e){l.mutationStore.markMutationError(t,e),l.dataStore.markMutationComplete({mutationId:t,optimisticResponse:i}),l.broadcastQueries(),l.setQuery(t,function(){return{document:null}}),a(new h({networkError:e}))},complete:function(){if(b&&l.mutationStore.markMutationError(t,b),l.dataStore.markMutationComplete({mutationId:t,optimisticResponse:i}),l.broadcastQueries(),b)a(b);else{"function"==typeof c&&(c=c(y));var e=[];c.forEach(function(t){if("string"==typeof t)l.queries.forEach(function(r){var o=r.observableQuery;o&&o.queryName===t&&e.push(o.refetch())});else{var r={query:t.query,variables:t.variables,fetchPolicy:"network-only"};t.context&&(r.context=t.context),e.push(l.query(r))}}),Promise.all(p?e:[]).then(function(){l.setQuery(t,function(){return{document:null}}),"ignore"===d&&y&&r.graphQLResultHasError(y)&&delete y.errors,s(y)})}}})})]}})})},t.prototype.fetchQuery=function(t,o,n,s){return e.__awaiter(this,void 0,void 0,function(){var i,a,u,l,p,f,y,d,v,b,m,g,Q,w,S,k,q,R=this;return e.__generator(this,function(E){switch(E.label){case 0:return i=o.metadata,a=void 0===i?null:i,u=o.fetchPolicy,l=void 0===u?"cache-first":u,p=o.context,f=void 0===p?{}:p,y=this.transform(o.query).document,d=this.getVariables(y,o.variables),this.transform(y).hasClientExports?[4,this.localState.addExportedVariables(y,d,f)]:[3,2];case 1:d=E.sent(),E.label=2;case 2:if(o=e.__assign({},o,{variables:d}),b="network-only"===l||"no-cache"===l,n!==exports.FetchType.refetch&&"network-only"!==l&&"no-cache"!==l&&(m=this.dataStore.getCache().diff({query:y,variables:d,returnPartialData:!0,optimistic:!1}),g=m.complete,Q=m.result,b=!g||"cache-and-network"===l,v=Q),w=b&&"cache-only"!==l&&"standby"!==l,r.hasDirectives(["live"],y)&&(w=!0),S=this.idCounter++,k=this.updateQueryWatch(t,y,o),this.setQuery(t,function(){return{document:y,lastRequestId:S,invalidated:!0,cancel:k}}),this.invalidate(!0,s),this.queryStore.initQuery({queryId:t,document:y,storePreviousVariables:w,variables:d,isPoll:n===exports.FetchType.poll,isRefetch:n===exports.FetchType.refetch,metadata:a,fetchMoreForQueryId:s}),this.broadcastQueries(),w){if(q=this.fetchRequest({requestId:S,queryId:t,document:y,options:o,fetchMoreForQueryId:s}).catch(function(e){throw c(e)?e:(S>=R.getQuery(t).lastRequestId&&(R.queryStore.markQueryError(t,e,s),R.invalidate(!0,t,s),R.broadcastQueries()),new h({networkError:e}))}),"cache-and-network"!==l)return[2,q];q.catch(function(){})}return this.queryStore.markQueryResultClient(t,!w),this.invalidate(!0,t,s),this.transform(y).hasForcedResolvers?[2,this.localState.runResolvers({document:y,remoteResult:{data:v},context:f,variables:d,onlyRunForcedResolvers:!0}).then(function(e){return R.markQueryResult(t,e,o,s),R.broadcastQueries(),e})]:(this.broadcastQueries(),[2,{data:v}])}})})},t.prototype.markQueryResult=function(t,e,r,o){var n=r.fetchPolicy,s=r.variables,i=r.errorPolicy;"no-cache"===n?this.setQuery(t,function(){return{newData:{result:e.data,complete:!0}}}):this.dataStore.markQueryResult(e,this.getQuery(t).document,s,o,"ignore"===i||"all"===i)},t.prototype.queryListenerForObserver=function(t,e,r){var o=this;function n(t,e){if(r[t])try{r[t](e)}catch(t){}}return function(r,s){if(o.invalidate(!1,t),r){var i=o.getQuery(t),u=i.observableQuery,c=i.document,l=u?u.options.fetchPolicy:e.fetchPolicy;if("standby"!==l){var p=a(r.networkStatus),f=u&&u.getLastResult();if(!p||"cache-only"===l||"cache-and-network"===l||!s&&r.previousVariables||f&&f.networkStatus!==r.networkStatus&&e.notifyOnNetworkStatusChange){var y=r.graphQLErrors&&r.graphQLErrors.length>0,d=u&&u.options.errorPolicy||e.errorPolicy||"none";if("none"===d&&y||r.networkError)return n("error",new h({graphQLErrors:r.graphQLErrors,networkError:r.networkError}));try{var v=void 0,b=void 0;if(s)"no-cache"!==l&&"network-only"!==l&&o.setQuery(t,function(){return{newData:null}}),v=s.result,b=!s.complete;else{var m=u&&u.getLastError(),g="none"!==d&&(m&&m.graphQLErrors)!==r.graphQLErrors;if(f&&f.data&&!g)v=f.data,b=!1;else{var Q=o.dataStore.getCache().diff({query:c,variables:r.previousVariables||r.variables,optimistic:!0});v=Q.result,b=!Q.complete}}var w=b&&"cache-only"!==l,S={data:w?f&&f.data:v,loading:p,networkStatus:r.networkStatus,stale:w};"all"===d&&y&&(S.errors=r.graphQLErrors),n("next",S)}catch(t){n("error",new h({networkError:t}))}}}}}},t.prototype.transform=function(t){var e=this.transformCache;if(!e.has(t)){var o=this.dataStore.getCache(),n=o.transformDocument(t),s=r.removeConnectionDirectiveFromDocument(o.transformForLink(n)),i=this.localState.clientQuery(n),a=this.localState.serverQuery(s),u={document:n,hasClientExports:r.hasClientExports(n),hasForcedResolvers:this.localState.shouldForceResolvers(n),clientQuery:i,serverQuery:a,defaultVars:r.getDefaultValues(r.getOperationDefinition(n))},c=function(t){t&&!e.has(t)&&e.set(t,u)};c(t),c(n),c(i),c(a)}return e.get(t)},t.prototype.getVariables=function(t,r){return e.__assign({},this.transform(t).defaultVars,r)},t.prototype.watchQuery=function(t,r){void 0===r&&(r=!0),s.invariant("standby"!==t.fetchPolicy,9),t.variables=this.getVariables(t.query,t.variables),void 0===t.notifyOnNetworkStatusChange&&(t.notifyOnNetworkStatusChange=!1);var o=e.__assign({},t);return new f({queryManager:this,options:o,shouldSubscribe:r})},t.prototype.query=function(t){var e=this;return s.invariant(t.query,10),s.invariant("Document"===t.query.kind,11),s.invariant(!t.returnPartialData,12),s.invariant(!t.pollInterval,13),new Promise(function(r,o){var n=e.watchQuery(t,!1);e.fetchQueryRejectFns.set("query:"+n.queryId,o),n.result().then(r,o).then(function(){return e.fetchQueryRejectFns.delete("query:"+n.queryId)})})},t.prototype.generateQueryId=function(){return String(this.idCounter++)},t.prototype.stopQueryInStore=function(t){this.stopQueryInStoreNoBroadcast(t),this.broadcastQueries()},t.prototype.stopQueryInStoreNoBroadcast=function(t){this.stopPollingQuery(t),this.queryStore.stopQuery(t),this.invalidate(!0,t)},t.prototype.addQueryListener=function(t,e){this.setQuery(t,function(t){return t.listeners.add(e),{invalidated:!1}})},t.prototype.updateQueryWatch=function(t,e,r){var o=this,n=this.getQuery(t).cancel;n&&n();return this.dataStore.getCache().watch({query:e,variables:r.variables,optimistic:!0,previousResult:function(){var e=null,r=o.getQuery(t).observableQuery;if(r){var n=r.getLastResult();n&&(e=n.data)}return e},callback:function(e){o.setQuery(t,function(){return{invalidated:!0,newData:e}})}})},t.prototype.addObservableQuery=function(t,e){this.setQuery(t,function(){return{observableQuery:e}})},t.prototype.removeObservableQuery=function(t){var e=this.getQuery(t).cancel;this.setQuery(t,function(){return{observableQuery:null}}),e&&e()},t.prototype.clearStore=function(){this.fetchQueryRejectFns.forEach(function(t){t(new s.InvariantError(14))});var t=[];return this.queries.forEach(function(e,r){e.observableQuery&&t.push(r)}),this.queryStore.reset(t),this.mutationStore.reset(),this.dataStore.reset()},t.prototype.resetStore=function(){var t=this;return this.clearStore().then(function(){return t.reFetchObservableQueries()})},t.prototype.reFetchObservableQueries=function(t){var e=this;void 0===t&&(t=!1);var r=[];return this.queries.forEach(function(o,n){var s=o.observableQuery;if(s){var i=s.options.fetchPolicy;s.resetLastResults(),"cache-only"===i||!t&&"standby"===i||r.push(s.refetch()),e.setQuery(n,function(){return{newData:null}}),e.invalidate(!0,n)}}),this.broadcastQueries(),Promise.all(r)},t.prototype.observeQuery=function(t,e,r){return this.addQueryListener(t,this.queryListenerForObserver(t,e,r)),this.fetchQuery(t,e)},t.prototype.startQuery=function(t,e,r){return this.addQueryListener(t,r),this.fetchQuery(t,e).catch(function(){}),t},t.prototype.startGraphQLSubscription=function(t){var e=this,o=t.query,n=t.fetchPolicy,s=t.variables;o=this.transform(o).document,s=this.getVariables(o,s);var i=function(t){return e.getObservableFromLink(o,{},t,!1).map(function(s){if(n&&"no-cache"===n||(e.dataStore.markSubscriptionResult(s,o,t),e.broadcastQueries()),r.graphQLResultHasError(s))throw new h({graphQLErrors:s.errors});return s})};if(this.transform(o).hasClientExports){var a=this.localState.addExportedVariables(o,s).then(i);return new u(function(t){var e=null;return a.then(function(r){return e=r.subscribe(t)},t.error),function(){return e&&e.unsubscribe()}})}return i(s)},t.prototype.stopQuery=function(t){this.stopQueryNoBroadcast(t),this.broadcastQueries()},t.prototype.stopQueryNoBroadcast=function(t){this.stopQueryInStoreNoBroadcast(t),this.removeQuery(t)},t.prototype.removeQuery=function(t){this.fetchQueryRejectFns.delete("query:"+t),this.fetchQueryRejectFns.delete("fetchRequest:"+t),this.getQuery(t).subscriptions.forEach(function(t){return t.unsubscribe()}),this.queries.delete(t)},t.prototype.getCurrentQueryResult=function(t,e){void 0===e&&(e=!0);var r=t.options,o=r.variables,n=r.query,s=r.fetchPolicy,i=t.getLastResult(),a=this.getQuery(t.queryId).newData;if(a&&a.complete)return{data:a.result,partial:!1};if("no-cache"===s||"network-only"===s)return{data:void 0,partial:!1};try{return{data:this.dataStore.getCache().read({query:n,variables:o,previousResult:i?i.data:void 0,optimistic:e})||void 0,partial:!1}}catch(t){return{data:void 0,partial:!0}}},t.prototype.getQueryWithPreviousResult=function(t){var e;if("string"==typeof t){var r=this.getQuery(t).observableQuery;s.invariant(r,15),e=r}else e=t;var o=e.options,n=o.variables,i=o.query;return{previousResult:this.getCurrentQueryResult(e,!1).data,variables:n,document:i}},t.prototype.broadcastQueries=function(){var t=this;this.onBroadcast(),this.queries.forEach(function(e,r){e.invalidated&&e.listeners.forEach(function(o){o&&o(t.queryStore.get(r),e.newData)})})},t.prototype.getLocalState=function(){return this.localState},t.prototype.getObservableFromLink=function(t,n,s,i){var a,c=this;void 0===i&&(i=this.queryDeduplication);var l=this.transform(t).serverQuery;if(l){var h=this.inFlightLinkObservables,p=this.link,f={query:l,variables:s,operationName:r.getOperationName(l)||void 0,context:this.prepareContext(e.__assign({},n,{forceFetch:!i}))};if(n=f.context,i){var y=h.get(l)||new Map;h.set(l,y);var d=JSON.stringify(s);if(!(a=y.get(d))){y.set(d,a=Q(o.execute(p,f)));var v=function(){y.delete(d),y.size||h.delete(l),b.unsubscribe()},b=a.subscribe({next:v,error:v,complete:v})}}else a=Q(o.execute(p,f))}else a=u.of({data:{}}),n=this.prepareContext(n);var m=this.transform(t).clientQuery;return m&&(a=w(a,function(t){return c.localState.runResolvers({document:m,remoteResult:t,context:n,variables:s})})),a},t.prototype.fetchRequest=function(t){var e,r,o=this,n=t.requestId,s=t.queryId,i=t.document,a=t.options,u=t.fetchMoreForQueryId,c=a.variables,l=a.errorPolicy,p=void 0===l?"none":l,f=a.fetchPolicy;return new Promise(function(t,l){var y=o.getObservableFromLink(i,a.context,c),d="fetchRequest:"+s;o.fetchQueryRejectFns.set(d,l);var v=function(){o.fetchQueryRejectFns.delete(d),o.setQuery(s,function(t){t.subscriptions.delete(b)})},b=y.map(function(t){if(n>=o.getQuery(s).lastRequestId&&(o.markQueryResult(s,t,a,u),o.queryStore.markQueryResult(s,t,u),o.invalidate(!0,s,u),o.broadcastQueries()),t.errors&&"none"===p)throw new h({graphQLErrors:t.errors});if("all"===p&&(r=t.errors),u||"no-cache"===f)e=t.data;else try{e=o.dataStore.getCache().read({variables:c,query:i,optimistic:!1})}catch(t){}return e}).subscribe({error:function(t){v(),l(t)},complete:function(){v(),t({data:e,errors:r,loading:!1,networkStatus:exports.NetworkStatus.ready,stale:!1})}});o.setQuery(s,function(t){t.subscriptions.add(b)})})},t.prototype.getQuery=function(t){return this.queries.get(t)||{listeners:new Set,invalidated:!1,document:null,newData:null,lastRequestId:1,observableQuery:null,subscriptions:new Set}},t.prototype.setQuery=function(t,r){var o=this.getQuery(t),n=e.__assign({},o,r(o));this.queries.set(t,n)},t.prototype.invalidate=function(t,e,r){e&&this.setQuery(e,function(){return{invalidated:t}}),r&&this.setQuery(r,function(){return{invalidated:t}})},t.prototype.prepareContext=function(t){void 0===t&&(t={});var r=this.localState.prepareContext(t);return e.__assign({},r,{clientAwareness:this.clientAwareness})},t.prototype.checkInFlight=function(t){var e=this.queryStore.get(t);return e&&e.networkStatus!==exports.NetworkStatus.ready&&e.networkStatus!==exports.NetworkStatus.error},t.prototype.startPollingQuery=function(t,r,o){var n=t.pollInterval;return s.invariant(n,16),this.ssrMode||(this.pollingInfoByQueryId.set(r,{interval:n,lastPollTimeMs:Date.now()-10,options:e.__assign({},t,{fetchPolicy:"network-only"})}),o&&this.addQueryListener(r,o),this.schedulePoll(n)),r},t.prototype.stopPollingQuery=function(t){this.pollingInfoByQueryId.delete(t)},t.prototype.schedulePoll=function(t){var e=this,r=Date.now();if(this.nextPoll){if(!(t<this.nextPoll.time-r))return;clearTimeout(this.nextPoll.timeout)}this.nextPoll={time:r+t,timeout:setTimeout(function(){e.nextPoll=null;var t=1/0;e.pollingInfoByQueryId.forEach(function(r,o){if(r.interval<t&&(t=r.interval),!e.checkInFlight(o)&&Date.now()-r.lastPollTimeMs>=r.interval){var n=function(){r.lastPollTimeMs=Date.now()};e.fetchQuery(o,r.options,exports.FetchType.poll).then(n,n)}}),isFinite(t)&&e.schedulePoll(t)},t)}},t}(),q=function(){function t(t){this.cache=t}return t.prototype.getCache=function(){return this.cache},t.prototype.markQueryResult=function(t,e,o,n,s){void 0===s&&(s=!1);var i=!r.graphQLResultHasError(t);s&&r.graphQLResultHasError(t)&&t.data&&(i=!0),!n&&i&&this.cache.write({result:t.data,dataId:"ROOT_QUERY",query:e,variables:o})},t.prototype.markSubscriptionResult=function(t,e,o){r.graphQLResultHasError(t)||this.cache.write({result:t.data,dataId:"ROOT_SUBSCRIPTION",query:e,variables:o})},t.prototype.markMutationInit=function(t){var e,r=this;t.optimisticResponse&&(e="function"==typeof t.optimisticResponse?t.optimisticResponse(t.variables):t.optimisticResponse,this.cache.recordOptimisticTransaction(function(o){var n=r.cache;r.cache=o;try{r.markMutationResult({mutationId:t.mutationId,result:{data:e},document:t.document,variables:t.variables,updateQueries:t.updateQueries,update:t.update})}finally{r.cache=n}},t.mutationId))},t.prototype.markMutationResult=function(t){var e=this;if(!r.graphQLResultHasError(t.result)){var o=[];o.push({result:t.result.data,dataId:"ROOT_MUTATION",query:t.document,variables:t.variables}),t.updateQueries&&Object.keys(t.updateQueries).filter(function(e){return t.updateQueries[e]}).forEach(function(n){var s=t.updateQueries[n],i=s.query,a=s.updater,u=e.cache.diff({query:i.document,variables:i.variables,returnPartialData:!0,optimistic:!1}),c=u.result;if(u.complete){var l=r.tryFunctionOrLogError(function(){return a(c,{mutationResult:t.result,queryName:r.getOperationName(i.document)||void 0,queryVariables:i.variables})});l&&o.push({result:l,dataId:"ROOT_QUERY",query:i.document,variables:i.variables})}}),this.cache.performTransaction(function(e){o.forEach(function(t){return e.write(t)});var n=t.update;n&&r.tryFunctionOrLogError(function(){return n(e,t.result)})})}},t.prototype.markMutationComplete=function(t){var e=t.mutationId;t.optimisticResponse&&this.cache.removeOptimistic(e)},t.prototype.markUpdateQueryResult=function(t,e,r){this.cache.write({result:r,dataId:"ROOT_QUERY",variables:e,query:t})},t.prototype.reset=function(){return this.cache.reset()},t}(),R="2.6.0-beta.3",E=!1,_=function(){function t(t){var e=this;this.defaultOptions={},this.resetStoreCallbacks=[],this.clearStoreCallbacks=[];var r=t.cache,n=t.ssrMode,i=void 0!==n&&n,a=t.ssrForceFetchDelay,u=void 0===a?0:a,c=t.connectToDevTools,l=t.queryDeduplication,h=void 0===l||l,p=t.defaultOptions,f=t.assumeImmutableResults,y=void 0!==f&&f,d=t.resolvers,v=t.typeDefs,b=t.fragmentMatcher,m=t.name,Q=t.version,w=t.link;if(!w&&d&&(w=o.ApolloLink.empty()),!w||!r)throw new s.InvariantError(1);this.link=w,this.cache=r,this.store=new q(r),this.disableNetworkFetches=i||u>0,this.queryDeduplication=h,this.defaultOptions=p||{},this.typeDefs=v,u&&setTimeout(function(){return e.disableNetworkFetches=!1},u),this.watchQuery=this.watchQuery.bind(this),this.query=this.query.bind(this),this.mutate=this.mutate.bind(this),this.resetStore=this.resetStore.bind(this),this.reFetchObservableQueries=this.reFetchObservableQueries.bind(this);void 0!==c&&(c&&"undefined"!=typeof window)&&(window.__APOLLO_CLIENT__=this),this.version=R,this.localState=new g({cache:r,client:this,resolvers:d,fragmentMatcher:b}),this.queryManager=new k({link:this.link,store:this.store,queryDeduplication:h,ssrMode:i,clientAwareness:{name:m,version:Q},localState:this.localState,assumeImmutableResults:y,onBroadcast:function(){e.devToolsHookCb&&e.devToolsHookCb({action:{},state:{queries:e.queryManager.queryStore.getStore(),mutations:e.queryManager.mutationStore.getStore()},dataWithOptimisticResults:e.cache.extract(!0)})}})}return t.prototype.stop=function(){this.queryManager&&this.queryManager.stop()},t.prototype.watchQuery=function(t){return this.defaultOptions.watchQuery&&(t=e.__assign({},this.defaultOptions.watchQuery,t)),!this.disableNetworkFetches||"network-only"!==t.fetchPolicy&&"cache-and-network"!==t.fetchPolicy||(t=e.__assign({},t,{fetchPolicy:"cache-first"})),this.queryManager.watchQuery(t)},t.prototype.query=function(t){return this.defaultOptions.query&&(t=e.__assign({},this.defaultOptions.query,t)),s.invariant("cache-and-network"!==t.fetchPolicy,2),this.disableNetworkFetches&&"network-only"===t.fetchPolicy&&(t=e.__assign({},t,{fetchPolicy:"cache-first"})),this.queryManager.query(t)},t.prototype.mutate=function(t){return this.defaultOptions.mutate&&(t=e.__assign({},this.defaultOptions.mutate,t)),this.queryManager.mutate(t)},t.prototype.subscribe=function(t){return this.queryManager.startGraphQLSubscription(t)},t.prototype.readQuery=function(t,e){return void 0===e&&(e=!1),this.cache.readQuery(t,e)},t.prototype.readFragment=function(t,e){return void 0===e&&(e=!1),this.cache.readFragment(t,e)},t.prototype.writeQuery=function(t){var e=this.cache.writeQuery(t);return this.queryManager.broadcastQueries(),e},t.prototype.writeFragment=function(t){var e=this.cache.writeFragment(t);return this.queryManager.broadcastQueries(),e},t.prototype.writeData=function(t){var e=this.cache.writeData(t);return this.queryManager.broadcastQueries(),e},t.prototype.__actionHookForDevTools=function(t){this.devToolsHookCb=t},t.prototype.__requestRaw=function(t){return o.execute(this.link,t)},t.prototype.initQueryManager=function(){return this.queryManager},t.prototype.resetStore=function(){var t=this;return Promise.resolve().then(function(){return t.queryManager.clearStore()}).then(function(){return Promise.all(t.resetStoreCallbacks.map(function(t){return t()}))}).then(function(){return t.reFetchObservableQueries()})},t.prototype.clearStore=function(){var t=this;return Promise.resolve().then(function(){return Promise.all(t.clearStoreCallbacks.map(function(t){return t()}))}).then(function(){return t.queryManager.clearStore()})},t.prototype.onResetStore=function(t){var e=this;return this.resetStoreCallbacks.push(t),function(){e.resetStoreCallbacks=e.resetStoreCallbacks.filter(function(e){return e!==t})}},t.prototype.onClearStore=function(t){var e=this;return this.clearStoreCallbacks.push(t),function(){e.clearStoreCallbacks=e.clearStoreCallbacks.filter(function(e){return e!==t})}},t.prototype.reFetchObservableQueries=function(t){return this.queryManager.reFetchObservableQueries(t)},t.prototype.extract=function(t){return this.cache.extract(t)},t.prototype.restore=function(t){return this.cache.restore(t)},t.prototype.addResolvers=function(t){this.localState.addResolvers(t)},t.prototype.setResolvers=function(t){this.localState.setResolvers(t)},t.prototype.getResolvers=function(){return this.localState.getResolvers()},t.prototype.setLocalStateFragmentMatcher=function(t){this.localState.setFragmentMatcher(t)},t}();exports.ApolloClient=_,exports.ApolloError=h,exports.ObservableQuery=f,exports.default=_,exports.isApolloError=c;
"use strict";function t(t){return t&&"object"==typeof t&&"default"in t?t.default:t}Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),r=require("apollo-utilities"),o=require("apollo-link"),n=t(require("symbol-observable")),s=require("ts-invariant"),i=require("graphql/language/visitor");function a(t){return t<7}!function(t){t[t.loading=1]="loading",t[t.setVariables=2]="setVariables",t[t.fetchMore=3]="fetchMore",t[t.refetch=4]="refetch",t[t.poll=6]="poll",t[t.ready=7]="ready",t[t.error=8]="error"}(exports.NetworkStatus||(exports.NetworkStatus={}));var u=function(t){function r(){return null!==t&&t.apply(this,arguments)||this}return e.__extends(r,t),r.prototype[n]=function(){return this},r.prototype["@@observable"]=function(){return this},r}(o.Observable);function c(t){return t.hasOwnProperty("graphQLErrors")}var l=function(t){var e="";return Array.isArray(t.graphQLErrors)&&0!==t.graphQLErrors.length&&t.graphQLErrors.forEach(function(t){var r=t?t.message:"Error message not found.";e+="GraphQL error: "+r+"\n"}),t.networkError&&(e+="Network error: "+t.networkError.message+"\n"),e=e.replace(/\n$/,"")},h=function(t){function r(e){var o=e.graphQLErrors,n=e.networkError,s=e.errorMessage,i=e.extraInfo,a=t.call(this,s)||this;return a.graphQLErrors=o||[],a.networkError=n||null,a.message=s||l(a),a.extraInfo=i,a.__proto__=r.prototype,a}return e.__extends(r,t),r}(Error);!function(t){t[t.normal=1]="normal",t[t.refetch=2]="refetch",t[t.poll=3]="poll"}(exports.FetchType||(exports.FetchType={}));var p=function(t,e){return void 0===e&&(e="none"),t&&(t.graphQLErrors&&t.graphQLErrors.length>0&&"none"===e||t.networkError)},f=function(t){function o(e){var o=e.queryManager,n=e.options,s=e.shouldSubscribe,i=void 0===s||s,a=t.call(this,function(t){return a.onSubscribe(t)})||this;a.observers=new Set,a.subscriptions=new Set,a.isTornDown=!1,a.options=n,a.variables=n.variables||{},a.queryId=o.generateQueryId(),a.shouldSubscribe=i;var u=r.getOperationDefinition(n.query);return a.queryName=u&&u.name&&u.name.value,a.queryManager=o,a}return e.__extends(o,t),o.prototype.result=function(){var t=this;return new Promise(function(e,r){var o={next:function(r){e(r),t.observers.delete(o),t.observers.size||t.queryManager.removeQuery(t.queryId),setTimeout(function(){n.unsubscribe()},0)},error:r},n=t.subscribe(o)})},o.prototype.currentResult=function(){var t=this.getCurrentResult();return void 0===t.data&&(t.data={}),t},o.prototype.getCurrentResult=function(){if(this.isTornDown){var t=this.lastResult;return{data:!this.lastError&&t&&t.data||void 0,error:this.lastError,loading:!1,networkStatus:exports.NetworkStatus.error}}var r,o=this.queryManager.getCurrentQueryResult(this),n=o.data,s=o.partial,i=this.queryManager.queryStore.get(this.queryId);if(i){var u=i.networkStatus;if(p(i,this.options.errorPolicy))return{data:void 0,loading:!1,networkStatus:u,error:new h({graphQLErrors:i.graphQLErrors,networkError:i.networkError})};i.variables&&(this.options.variables=e.__assign({},this.options.variables,i.variables),this.variables=this.options.variables),r={data:n,loading:a(u),networkStatus:u},i.graphQLErrors&&"all"===this.options.errorPolicy&&(r.errors=i.graphQLErrors)}else{var c=this.options.fetchPolicy,l="network-only"===c||s&&"cache-only"!==c;r={data:n,loading:l,networkStatus:l?exports.NetworkStatus.loading:exports.NetworkStatus.ready}}return s||this.updateLastResult(e.__assign({},r,{stale:!1})),e.__assign({},r,{partial:s})},o.prototype.isDifferentFromLastResult=function(t){var e=this.lastResultSnapshot;return!(e&&t&&e.networkStatus===t.networkStatus&&e.stale===t.stale&&r.isEqual(e.data,t.data))},o.prototype.getLastResult=function(){return this.lastResult},o.prototype.getLastError=function(){return this.lastError},o.prototype.resetLastResults=function(){delete this.lastResult,delete this.lastResultSnapshot,delete this.lastError,this.isTornDown=!1},o.prototype.refetch=function(t){var o=this.options.fetchPolicy;return"cache-only"===o?Promise.reject(new s.InvariantError(3)):("no-cache"!==o&&(o="network-only"),r.isEqual(this.variables,t)||(this.variables=e.__assign({},this.variables,t)),r.isEqual(this.options.variables,this.variables)||(this.options.variables=e.__assign({},this.options.variables,this.variables)),this.queryManager.fetchQuery(this.queryId,e.__assign({},this.options,{fetchPolicy:o}),exports.FetchType.refetch))},o.prototype.fetchMore=function(t){var r=this;s.invariant(t.updateQuery,4);var o=e.__assign({},t.query?t:e.__assign({},this.options,t,{variables:e.__assign({},this.variables,t.variables)}),{fetchPolicy:"network-only"});return this.queryManager.fetchQuery(this.queryManager.generateQueryId(),o,exports.FetchType.normal,this.queryId).then(function(e){return r.updateQuery(function(r){return t.updateQuery(r,{fetchMoreResult:e.data,variables:o.variables})}),e})},o.prototype.subscribeToMore=function(t){var e=this,r=this.queryManager.startGraphQLSubscription({query:t.document,variables:t.variables}).subscribe({next:function(r){var o=t.updateQuery;o&&e.updateQuery(function(t,e){var n=e.variables;return o(t,{subscriptionData:r,variables:n})})},error:function(e){t.onError&&t.onError(e)}});return this.subscriptions.add(r),function(){e.subscriptions.delete(r)&&r.unsubscribe()}},o.prototype.setOptions=function(t){var r=this.options.fetchPolicy;this.options=e.__assign({},this.options,t),t.pollInterval?this.startPolling(t.pollInterval):0===t.pollInterval&&this.stopPolling();var o=t.fetchPolicy;return this.setVariables(this.options.variables,r!==o&&("cache-only"===r||"standby"===r||"network-only"===o),t.fetchResults)},o.prototype.setVariables=function(t,e,o){return void 0===e&&(e=!1),void 0===o&&(o=!0),this.isTornDown=!1,t=t||this.variables,!e&&r.isEqual(t,this.variables)?this.observers.size&&o?this.result():Promise.resolve():(this.variables=this.options.variables=t,this.observers.size?this.queryManager.fetchQuery(this.queryId,this.options):Promise.resolve())},o.prototype.updateQuery=function(t){var e=this.queryManager,o=e.getQueryWithPreviousResult(this.queryId),n=o.previousResult,s=o.variables,i=o.document,a=r.tryFunctionOrLogError(function(){return t(n,{variables:s})});a&&(e.dataStore.markUpdateQueryResult(i,s,a),e.broadcastQueries())},o.prototype.stopPolling=function(){this.queryManager.stopPollingQuery(this.queryId),this.options.pollInterval=void 0},o.prototype.startPolling=function(t){d(this),this.options.pollInterval=t,this.queryManager.startPollingQuery(this.options,this.queryId)},o.prototype.updateLastResult=function(t){var e=this.lastResult;return this.lastResult=t,this.lastResultSnapshot=this.queryManager.assumeImmutableResults?t:r.cloneDeep(t),e},o.prototype.onSubscribe=function(t){var e=this,r=!this.observers.size;return this.observers.add(t),t.next&&this.lastResult&&t.next(this.lastResult),t.error&&this.lastError&&t.error(this.lastError),r&&this.setUpQuery(),function(){e.observers.delete(t)&&!e.observers.size&&e.tearDownQuery()}},o.prototype.setUpQuery=function(){var t=this,e=this.queryManager,o=this.queryId;this.shouldSubscribe&&e.addObservableQuery(o,this),this.options.pollInterval&&(d(this),e.startPollingQuery(this.options,o));var n=function(e){y(t.observers,"error",t.lastError=e)};e.observeQuery(o,this.options,{next:function(o){if(t.lastError||t.isDifferentFromLastResult(o)){var n=t.updateLastResult(o),s=t.options,i=s.query,a=s.variables,u=s.fetchPolicy;e.transform(i).hasClientExports?e.getLocalState().addExportedVariables(i,a).then(function(s){var a=t.variables;t.variables=t.options.variables=s,!o.loading&&n&&"cache-only"!==u&&e.transform(i).serverQuery&&!r.isEqual(a,s)?t.refetch():y(t.observers,"next",o)}):y(t.observers,"next",o)}},error:n}).catch(n)},o.prototype.tearDownQuery=function(){var t=this.queryManager;this.isTornDown=!0,t.stopPollingQuery(this.queryId),this.subscriptions.forEach(function(t){return t.unsubscribe()}),this.subscriptions.clear(),t.removeObservableQuery(this.queryId),t.stopQuery(this.queryId),this.observers.clear()},o}(u);function y(t,e,r){var o=[];t.forEach(function(t){return t[e]&&o.push(t)}),o.forEach(function(t){return t[e](r)})}function d(t){var e=t.options.fetchPolicy;s.invariant("cache-first"!==e&&"cache-only"!==e,5)}var v=function(){function t(){this.store={}}return t.prototype.getStore=function(){return this.store},t.prototype.get=function(t){return this.store[t]},t.prototype.initMutation=function(t,e,r){this.store[t]={mutation:e,variables:r||{},loading:!0,error:null}},t.prototype.markMutationError=function(t,e){var r=this.store[t];r&&(r.loading=!1,r.error=e)},t.prototype.markMutationResult=function(t){var e=this.store[t];e&&(e.loading=!1,e.error=null)},t.prototype.reset=function(){this.store={}},t}(),b=function(){function t(){this.store={}}return t.prototype.getStore=function(){return this.store},t.prototype.get=function(t){return this.store[t]},t.prototype.initQuery=function(t){var e=this.store[t.queryId];if(e&&e.document!==t.document&&!r.isEqual(e.document,t.document))throw new s.InvariantError(19);var o,n=!1,i=null;t.storePreviousVariables&&e&&e.networkStatus!==exports.NetworkStatus.loading&&(r.isEqual(e.variables,t.variables)||(n=!0,i=e.variables)),o=n?exports.NetworkStatus.setVariables:t.isPoll?exports.NetworkStatus.poll:t.isRefetch?exports.NetworkStatus.refetch:exports.NetworkStatus.loading;var a=[];e&&e.graphQLErrors&&(a=e.graphQLErrors),this.store[t.queryId]={document:t.document,variables:t.variables,previousVariables:i,networkError:null,graphQLErrors:a,networkStatus:o,metadata:t.metadata},"string"==typeof t.fetchMoreForQueryId&&this.store[t.fetchMoreForQueryId]&&(this.store[t.fetchMoreForQueryId].networkStatus=exports.NetworkStatus.fetchMore)},t.prototype.markQueryResult=function(t,e,r){this.store&&this.store[t]&&(this.store[t].networkError=null,this.store[t].graphQLErrors=e.errors&&e.errors.length?e.errors:[],this.store[t].previousVariables=null,this.store[t].networkStatus=exports.NetworkStatus.ready,"string"==typeof r&&this.store[r]&&(this.store[r].networkStatus=exports.NetworkStatus.ready))},t.prototype.markQueryError=function(t,e,r){this.store&&this.store[t]&&(this.store[t].networkError=e,this.store[t].networkStatus=exports.NetworkStatus.error,"string"==typeof r&&this.markQueryResultClient(r,!0))},t.prototype.markQueryResultClient=function(t,e){this.store&&this.store[t]&&(this.store[t].networkError=null,this.store[t].previousVariables=null,this.store[t].networkStatus=e?exports.NetworkStatus.ready:exports.NetworkStatus.loading)},t.prototype.stopQuery=function(t){delete this.store[t]},t.prototype.reset=function(t){var r=this;this.store=Object.keys(this.store).filter(function(e){return t.indexOf(e)>-1}).reduce(function(t,o){return t[o]=e.__assign({},r.store[o],{networkStatus:exports.NetworkStatus.loading}),t},{})},t}();function m(t){return t.charAt(0).toUpperCase()+t.slice(1)}var g=function(){function t(t){var e=t.cache,r=t.client,o=t.resolvers,n=t.fragmentMatcher;this.cache=e,r&&(this.client=r),o&&this.addResolvers(o),n&&this.setFragmentMatcher(n)}return t.prototype.addResolvers=function(t){var e=this;this.resolvers=this.resolvers||{},Array.isArray(t)?t.forEach(function(t){e.resolvers=r.mergeDeep(e.resolvers,t)}):this.resolvers=r.mergeDeep(this.resolvers,t)},t.prototype.setResolvers=function(t){this.resolvers={},this.addResolvers(t)},t.prototype.getResolvers=function(){return this.resolvers||{}},t.prototype.runResolvers=function(t){var r=t.document,o=t.remoteResult,n=t.context,s=t.variables,i=t.onlyRunForcedResolvers,a=void 0!==i&&i;return e.__awaiter(this,void 0,void 0,function(){return e.__generator(this,function(t){return r?[2,this.resolveDocument(r,o.data,n,s,this.fragmentMatcher,a).then(function(t){return e.__assign({},o,{data:t.result})})]:[2,o]})})},t.prototype.setFragmentMatcher=function(t){this.fragmentMatcher=t},t.prototype.getFragmentMatcher=function(){return this.fragmentMatcher},t.prototype.clientQuery=function(t){return r.hasDirectives(["client"],t)&&this.resolvers?t:null},t.prototype.serverQuery=function(t){return this.resolvers?r.removeClientSetsFromDocument(t):t},t.prototype.prepareContext=function(t){void 0===t&&(t={});var r=this.cache;return e.__assign({},t,{cache:r,getCacheKey:function(t){if(r.config)return r.config.dataIdFromObject(t);s.invariant(!1,17)}})},t.prototype.addExportedVariables=function(t,r,o){return void 0===r&&(r={}),void 0===o&&(o={}),e.__awaiter(this,void 0,void 0,function(){return e.__generator(this,function(n){return t?[2,this.resolveDocument(t,this.buildRootValueFromCache(t,r)||{},this.prepareContext(o),r).then(function(t){return e.__assign({},r,t.exportedVariables)})]:[2,e.__assign({},r)]})})},t.prototype.shouldForceResolvers=function(t){var e=!1;return i.visit(t,{Directive:{enter:function(t){if("client"===t.name.value&&t.arguments&&(e=t.arguments.some(function(t){return"always"===t.name.value&&"BooleanValue"===t.value.kind&&!0===t.value.value})))return i.BREAK}}}),e},t.prototype.shouldForceResolver=function(t){return this.shouldForceResolvers(t)},t.prototype.buildRootValueFromCache=function(t,e){return this.cache.diff({query:r.buildQueryFromSelectionSet(t),variables:e,optimistic:!1}).result},t.prototype.resolveDocument=function(t,o,n,s,i,a){return void 0===n&&(n={}),void 0===s&&(s={}),void 0===i&&(i=function(){return!0}),void 0===a&&(a=!1),e.__awaiter(this,void 0,void 0,function(){var u,c,l,h,p,f,y,d,v;return e.__generator(this,function(b){return u=r.getMainDefinition(t),c=r.getFragmentDefinitions(t),l=r.createFragmentMap(c),h=u.operation,p=h?m(h):"Query",y=(f=this).cache,d=f.client,v={fragmentMap:l,context:e.__assign({},n,{cache:y,client:d}),variables:s,fragmentMatcher:i,defaultOperationType:p,exportedVariables:{},onlyRunForcedResolvers:a},[2,this.resolveSelectionSet(u.selectionSet,o,v).then(function(t){return{result:t,exportedVariables:v.exportedVariables}})]})})},t.prototype.resolveSelectionSet=function(t,o,n){return e.__awaiter(this,void 0,void 0,function(){var i,a,u,c,l,h=this;return e.__generator(this,function(p){return i=n.fragmentMap,a=n.context,u=n.variables,c=[o],l=function(t){return e.__awaiter(h,void 0,void 0,function(){var l,h;return e.__generator(this,function(e){return r.shouldInclude(t,u)?r.isField(t)?[2,this.resolveField(t,o,n).then(function(e){var o;void 0!==e&&c.push(((o={})[r.resultKeyNameFromField(t)]=e,o))})]:(r.isInlineFragment(t)?l=t:(l=i[t.name.value],s.invariant(l,18)),l&&l.typeCondition&&(h=l.typeCondition.name.value,n.fragmentMatcher(o,h,a))?[2,this.resolveSelectionSet(l.selectionSet,o,n).then(function(t){c.push(t)})]:[2]):[2]})})},[2,Promise.all(t.selections.map(l)).then(function(){return r.mergeDeepArray(c)})]})})},t.prototype.resolveField=function(t,o,n){return e.__awaiter(this,void 0,void 0,function(){var s,i,a,u,c,l,h,p,f,y=this;return e.__generator(this,function(e){return s=n.variables,i=t.name.value,a=r.resultKeyNameFromField(t),u=i!==a,c=o[a]||o[i],l=Promise.resolve(c),n.onlyRunForcedResolvers&&!this.shouldForceResolver(t)||(h=o.__typename||n.defaultOperationType,(p=this.resolvers&&this.resolvers[h])&&(f=p[u?i:a])&&(l=Promise.resolve(f(o,r.argumentsObjectFromField(t,s),n.context,{field:t})))),[2,l.then(function(e){return void 0===e&&(e=c),t.directives&&t.directives.forEach(function(t){"export"===t.name.value&&t.arguments&&t.arguments.forEach(function(t){"as"===t.name.value&&"StringValue"===t.value.kind&&(n.exportedVariables[t.value.value]=e)})}),t.selectionSet?null==e?e:Array.isArray(e)?y.resolveSubSelectedArray(t,e,n):t.selectionSet?y.resolveSelectionSet(t.selectionSet,e,n):void 0:e})]})})},t.prototype.resolveSubSelectedArray=function(t,e,r){var o=this;return Promise.all(e.map(function(e){return null===e?null:Array.isArray(e)?o.resolveSubSelectedArray(t,e,r):t.selectionSet?o.resolveSelectionSet(t.selectionSet,e,r):void 0}))},t}();function Q(t){var e=new Set,r=null;return new u(function(o){return e.add(o),r=r||t.subscribe({next:function(t){e.forEach(function(e){return e.next&&e.next(t)})},error:function(t){e.forEach(function(e){return e.error&&e.error(t)})},complete:function(){e.forEach(function(t){return t.complete&&t.complete()})}}),function(){e.delete(o)&&!e.size&&r&&(r.unsubscribe(),r=null)}})}function w(t,e){return new u(function(r){var o=r.next,n=r.error,s=r.complete,i=0,a=!1,u={next:function(t){++i,new Promise(function(r){r(e(t))}).then(function(t){--i,o&&o.call(r,t),a&&u.complete()},function(t){--i,n&&n.call(r,t)})},error:function(t){n&&n.call(r,t)},complete:function(){a=!0,i||s&&s.call(r)}},c=t.subscribe(u);return function(){return c.unsubscribe()}})}var S=Object.prototype.hasOwnProperty,k=function(){function t(t){var e=t.link,o=t.queryDeduplication,n=void 0!==o&&o,s=t.store,i=t.onBroadcast,a=void 0===i?function(){}:i,u=t.ssrMode,c=void 0!==u&&u,l=t.clientAwareness,h=void 0===l?{}:l,p=t.localState,f=t.assumeImmutableResults;this.mutationStore=new v,this.queryStore=new b,this.clientAwareness={},this.idCounter=1,this.queries=new Map,this.fetchQueryRejectFns=new Map,this.transformCache=new(r.canUseWeakMap?WeakMap:Map),this.inFlightLinkObservables=new Map,this.pollingInfoByQueryId=new Map,this.nextPoll=null,this.link=e,this.queryDeduplication=n,this.dataStore=s,this.onBroadcast=a,this.clientAwareness=h,this.localState=p||new g({cache:s.getCache()}),this.ssrMode=c,this.assumeImmutableResults=!!f}return t.prototype.stop=function(){var t=this;this.queries.forEach(function(e,r){t.stopQueryNoBroadcast(r)}),this.fetchQueryRejectFns.forEach(function(t){t(new s.InvariantError(6))})},t.prototype.mutate=function(t){var o=t.mutation,n=t.variables,i=t.optimisticResponse,a=t.updateQueries,u=t.refetchQueries,c=void 0===u?[]:u,l=t.awaitRefetchQueries,p=void 0!==l&&l,f=t.update,y=t.errorPolicy,d=void 0===y?"none":y,v=t.fetchPolicy,b=t.context,m=void 0===b?{}:b;return e.__awaiter(this,void 0,void 0,function(){var t,u,l,y=this;return e.__generator(this,function(b){switch(b.label){case 0:return s.invariant(o,7),s.invariant(!v||"no-cache"===v,8),t=this.generateQueryId(),o=this.transform(o).document,this.setQuery(t,function(){return{document:o}}),n=this.getVariables(o,n),this.transform(o).hasClientExports?[4,this.localState.addExportedVariables(o,n,m)]:[3,2];case 1:n=b.sent(),b.label=2;case 2:return u=function(){var t={};return a&&y.queries.forEach(function(e,r){var o=e.observableQuery;if(o){var n=o.queryName;n&&S.call(a,n)&&(t[r]={updater:a[n],query:y.queryStore.get(r)})}}),t},this.mutationStore.initMutation(t,o,n),this.dataStore.markMutationInit({mutationId:t,document:o,variables:n,updateQueries:u(),update:f,optimisticResponse:i}),this.broadcastQueries(),l=this,[2,new Promise(function(s,a){var y,b;l.getObservableFromLink(o,e.__assign({},m,{optimisticResponse:i}),n,!1).subscribe({next:function(e){r.graphQLResultHasError(e)&&"none"===d?b=new h({graphQLErrors:e.errors}):(l.mutationStore.markMutationResult(t),"no-cache"!==v&&l.dataStore.markMutationResult({mutationId:t,result:e,document:o,variables:n,updateQueries:u(),update:f}),y=e)},error:function(e){l.mutationStore.markMutationError(t,e),l.dataStore.markMutationComplete({mutationId:t,optimisticResponse:i}),l.broadcastQueries(),l.setQuery(t,function(){return{document:null}}),a(new h({networkError:e}))},complete:function(){if(b&&l.mutationStore.markMutationError(t,b),l.dataStore.markMutationComplete({mutationId:t,optimisticResponse:i}),l.broadcastQueries(),b)a(b);else{"function"==typeof c&&(c=c(y));var e=[];c.forEach(function(t){if("string"==typeof t)l.queries.forEach(function(r){var o=r.observableQuery;o&&o.queryName===t&&e.push(o.refetch())});else{var r={query:t.query,variables:t.variables,fetchPolicy:"network-only"};t.context&&(r.context=t.context),e.push(l.query(r))}}),Promise.all(p?e:[]).then(function(){l.setQuery(t,function(){return{document:null}}),"ignore"===d&&y&&r.graphQLResultHasError(y)&&delete y.errors,s(y)})}}})})]}})})},t.prototype.fetchQuery=function(t,o,n,s){return e.__awaiter(this,void 0,void 0,function(){var i,a,u,l,p,f,y,d,v,b,m,g,Q,w,S,k,q,R=this;return e.__generator(this,function(E){switch(E.label){case 0:return i=o.metadata,a=void 0===i?null:i,u=o.fetchPolicy,l=void 0===u?"cache-first":u,p=o.context,f=void 0===p?{}:p,y=this.transform(o.query).document,d=this.getVariables(y,o.variables),this.transform(y).hasClientExports?[4,this.localState.addExportedVariables(y,d,f)]:[3,2];case 1:d=E.sent(),E.label=2;case 2:if(o=e.__assign({},o,{variables:d}),b="network-only"===l||"no-cache"===l,n!==exports.FetchType.refetch&&"network-only"!==l&&"no-cache"!==l&&(m=this.dataStore.getCache().diff({query:y,variables:d,returnPartialData:!0,optimistic:!1}),g=m.complete,Q=m.result,b=!g||"cache-and-network"===l,v=Q),w=b&&"cache-only"!==l&&"standby"!==l,r.hasDirectives(["live"],y)&&(w=!0),S=this.idCounter++,k=this.updateQueryWatch(t,y,o),this.setQuery(t,function(){return{document:y,lastRequestId:S,invalidated:!0,cancel:k}}),this.invalidate(!0,s),this.queryStore.initQuery({queryId:t,document:y,storePreviousVariables:w,variables:d,isPoll:n===exports.FetchType.poll,isRefetch:n===exports.FetchType.refetch,metadata:a,fetchMoreForQueryId:s}),this.broadcastQueries(),w){if(q=this.fetchRequest({requestId:S,queryId:t,document:y,options:o,fetchMoreForQueryId:s}).catch(function(e){throw c(e)?e:(S>=R.getQuery(t).lastRequestId&&(R.queryStore.markQueryError(t,e,s),R.invalidate(!0,t,s),R.broadcastQueries()),new h({networkError:e}))}),"cache-and-network"!==l)return[2,q];q.catch(function(){})}return this.queryStore.markQueryResultClient(t,!w),this.invalidate(!0,t,s),this.transform(y).hasForcedResolvers?[2,this.localState.runResolvers({document:y,remoteResult:{data:v},context:f,variables:d,onlyRunForcedResolvers:!0}).then(function(e){return R.markQueryResult(t,e,o,s),R.broadcastQueries(),e})]:(this.broadcastQueries(),[2,{data:v}])}})})},t.prototype.markQueryResult=function(t,e,r,o){var n=r.fetchPolicy,s=r.variables,i=r.errorPolicy;"no-cache"===n?this.setQuery(t,function(){return{newData:{result:e.data,complete:!0}}}):this.dataStore.markQueryResult(e,this.getQuery(t).document,s,o,"ignore"===i||"all"===i)},t.prototype.queryListenerForObserver=function(t,e,r){var o=this;function n(t,e){if(r[t])try{r[t](e)}catch(t){}}return function(r,s){if(o.invalidate(!1,t),r){var i=o.getQuery(t),u=i.observableQuery,c=i.document,l=u?u.options.fetchPolicy:e.fetchPolicy;if("standby"!==l){var p=a(r.networkStatus),f=u&&u.getLastResult();if(!p||"cache-only"===l||"cache-and-network"===l||!s&&r.previousVariables||f&&f.networkStatus!==r.networkStatus&&e.notifyOnNetworkStatusChange){var y=r.graphQLErrors&&r.graphQLErrors.length>0,d=u&&u.options.errorPolicy||e.errorPolicy||"none";if("none"===d&&y||r.networkError)return n("error",new h({graphQLErrors:r.graphQLErrors,networkError:r.networkError}));try{var v=void 0,b=void 0;if(s)"no-cache"!==l&&"network-only"!==l&&o.setQuery(t,function(){return{newData:null}}),v=s.result,b=!s.complete;else{var m=u&&u.getLastError(),g="none"!==d&&(m&&m.graphQLErrors)!==r.graphQLErrors;if(f&&f.data&&!g)v=f.data,b=!1;else{var Q=o.dataStore.getCache().diff({query:c,variables:r.previousVariables||r.variables,optimistic:!0});v=Q.result,b=!Q.complete}}var w=b&&"cache-only"!==l,S={data:w?f&&f.data:v,loading:p,networkStatus:r.networkStatus,stale:w};"all"===d&&y&&(S.errors=r.graphQLErrors),n("next",S)}catch(t){n("error",new h({networkError:t}))}}}}}},t.prototype.transform=function(t){var e=this.transformCache;if(!e.has(t)){var o=this.dataStore.getCache(),n=o.transformDocument(t),s=r.removeConnectionDirectiveFromDocument(o.transformForLink(n)),i=this.localState.clientQuery(n),a=this.localState.serverQuery(s),u={document:n,hasClientExports:r.hasClientExports(n),hasForcedResolvers:this.localState.shouldForceResolvers(n),clientQuery:i,serverQuery:a,defaultVars:r.getDefaultValues(r.getOperationDefinition(n))},c=function(t){t&&!e.has(t)&&e.set(t,u)};c(t),c(n),c(i),c(a)}return e.get(t)},t.prototype.getVariables=function(t,r){return e.__assign({},this.transform(t).defaultVars,r)},t.prototype.watchQuery=function(t,r){void 0===r&&(r=!0),s.invariant("standby"!==t.fetchPolicy,9),t.variables=this.getVariables(t.query,t.variables),void 0===t.notifyOnNetworkStatusChange&&(t.notifyOnNetworkStatusChange=!1);var o=e.__assign({},t);return new f({queryManager:this,options:o,shouldSubscribe:r})},t.prototype.query=function(t){var e=this;return s.invariant(t.query,10),s.invariant("Document"===t.query.kind,11),s.invariant(!t.returnPartialData,12),s.invariant(!t.pollInterval,13),new Promise(function(r,o){var n=e.watchQuery(t,!1);e.fetchQueryRejectFns.set("query:"+n.queryId,o),n.result().then(r,o).then(function(){return e.fetchQueryRejectFns.delete("query:"+n.queryId)})})},t.prototype.generateQueryId=function(){return String(this.idCounter++)},t.prototype.stopQueryInStore=function(t){this.stopQueryInStoreNoBroadcast(t),this.broadcastQueries()},t.prototype.stopQueryInStoreNoBroadcast=function(t){this.stopPollingQuery(t),this.queryStore.stopQuery(t),this.invalidate(!0,t)},t.prototype.addQueryListener=function(t,e){this.setQuery(t,function(t){return t.listeners.add(e),{invalidated:!1}})},t.prototype.updateQueryWatch=function(t,e,r){var o=this,n=this.getQuery(t).cancel;n&&n();return this.dataStore.getCache().watch({query:e,variables:r.variables,optimistic:!0,previousResult:function(){var e=null,r=o.getQuery(t).observableQuery;if(r){var n=r.getLastResult();n&&(e=n.data)}return e},callback:function(e){o.setQuery(t,function(){return{invalidated:!0,newData:e}})}})},t.prototype.addObservableQuery=function(t,e){this.setQuery(t,function(){return{observableQuery:e}})},t.prototype.removeObservableQuery=function(t){var e=this.getQuery(t).cancel;this.setQuery(t,function(){return{observableQuery:null}}),e&&e()},t.prototype.clearStore=function(){this.fetchQueryRejectFns.forEach(function(t){t(new s.InvariantError(14))});var t=[];return this.queries.forEach(function(e,r){e.observableQuery&&t.push(r)}),this.queryStore.reset(t),this.mutationStore.reset(),this.dataStore.reset()},t.prototype.resetStore=function(){var t=this;return this.clearStore().then(function(){return t.reFetchObservableQueries()})},t.prototype.reFetchObservableQueries=function(t){var e=this;void 0===t&&(t=!1);var r=[];return this.queries.forEach(function(o,n){var s=o.observableQuery;if(s){var i=s.options.fetchPolicy;s.resetLastResults(),"cache-only"===i||!t&&"standby"===i||r.push(s.refetch()),e.setQuery(n,function(){return{newData:null}}),e.invalidate(!0,n)}}),this.broadcastQueries(),Promise.all(r)},t.prototype.observeQuery=function(t,e,r){return this.addQueryListener(t,this.queryListenerForObserver(t,e,r)),this.fetchQuery(t,e)},t.prototype.startQuery=function(t,e,r){return this.addQueryListener(t,r),this.fetchQuery(t,e).catch(function(){}),t},t.prototype.startGraphQLSubscription=function(t){var e=this,o=t.query,n=t.fetchPolicy,s=t.variables;o=this.transform(o).document,s=this.getVariables(o,s);var i=function(t){return e.getObservableFromLink(o,{},t,!1).map(function(s){if(n&&"no-cache"===n||(e.dataStore.markSubscriptionResult(s,o,t),e.broadcastQueries()),r.graphQLResultHasError(s))throw new h({graphQLErrors:s.errors});return s})};if(this.transform(o).hasClientExports){var a=this.localState.addExportedVariables(o,s).then(i);return new u(function(t){var e=null;return a.then(function(r){return e=r.subscribe(t)},t.error),function(){return e&&e.unsubscribe()}})}return i(s)},t.prototype.stopQuery=function(t){this.stopQueryNoBroadcast(t),this.broadcastQueries()},t.prototype.stopQueryNoBroadcast=function(t){this.stopQueryInStoreNoBroadcast(t),this.removeQuery(t)},t.prototype.removeQuery=function(t){this.fetchQueryRejectFns.delete("query:"+t),this.fetchQueryRejectFns.delete("fetchRequest:"+t),this.getQuery(t).subscriptions.forEach(function(t){return t.unsubscribe()}),this.queries.delete(t)},t.prototype.getCurrentQueryResult=function(t,e){void 0===e&&(e=!0);var r=t.options,o=r.variables,n=r.query,s=r.fetchPolicy,i=t.getLastResult(),a=this.getQuery(t.queryId).newData;if(a&&a.complete)return{data:a.result,partial:!1};if("no-cache"===s||"network-only"===s)return{data:void 0,partial:!1};try{return{data:this.dataStore.getCache().read({query:n,variables:o,previousResult:i?i.data:void 0,optimistic:e})||void 0,partial:!1}}catch(t){return{data:void 0,partial:!0}}},t.prototype.getQueryWithPreviousResult=function(t){var e;if("string"==typeof t){var r=this.getQuery(t).observableQuery;s.invariant(r,15),e=r}else e=t;var o=e.options,n=o.variables,i=o.query;return{previousResult:this.getCurrentQueryResult(e,!1).data,variables:n,document:i}},t.prototype.broadcastQueries=function(){var t=this;this.onBroadcast(),this.queries.forEach(function(e,r){e.invalidated&&e.listeners.forEach(function(o){o&&o(t.queryStore.get(r),e.newData)})})},t.prototype.getLocalState=function(){return this.localState},t.prototype.getObservableFromLink=function(t,n,s,i){var a,c=this;void 0===i&&(i=this.queryDeduplication);var l=this.transform(t).serverQuery;if(l){var h=this.inFlightLinkObservables,p=this.link,f={query:l,variables:s,operationName:r.getOperationName(l)||void 0,context:this.prepareContext(e.__assign({},n,{forceFetch:!i}))};if(n=f.context,i){var y=h.get(l)||new Map;h.set(l,y);var d=JSON.stringify(s);if(!(a=y.get(d))){y.set(d,a=Q(o.execute(p,f)));var v=function(){y.delete(d),y.size||h.delete(l),b.unsubscribe()},b=a.subscribe({next:v,error:v,complete:v})}}else a=Q(o.execute(p,f))}else a=u.of({data:{}}),n=this.prepareContext(n);var m=this.transform(t).clientQuery;return m&&(a=w(a,function(t){return c.localState.runResolvers({document:m,remoteResult:t,context:n,variables:s})})),a},t.prototype.fetchRequest=function(t){var e,r,o=this,n=t.requestId,s=t.queryId,i=t.document,a=t.options,u=t.fetchMoreForQueryId,c=a.variables,l=a.errorPolicy,p=void 0===l?"none":l,f=a.fetchPolicy;return new Promise(function(t,l){var y=o.getObservableFromLink(i,a.context,c),d="fetchRequest:"+s;o.fetchQueryRejectFns.set(d,l);var v=function(){o.fetchQueryRejectFns.delete(d),o.setQuery(s,function(t){t.subscriptions.delete(b)})},b=y.map(function(t){if(n>=o.getQuery(s).lastRequestId&&(o.markQueryResult(s,t,a,u),o.queryStore.markQueryResult(s,t,u),o.invalidate(!0,s,u),o.broadcastQueries()),t.errors&&"none"===p)throw new h({graphQLErrors:t.errors});if("all"===p&&(r=t.errors),u||"no-cache"===f)e=t.data;else try{e=o.dataStore.getCache().read({variables:c,query:i,optimistic:!1})}catch(t){}return e}).subscribe({error:function(t){v(),l(t)},complete:function(){v(),t({data:e,errors:r,loading:!1,networkStatus:exports.NetworkStatus.ready,stale:!1})}});o.setQuery(s,function(t){t.subscriptions.add(b)})})},t.prototype.getQuery=function(t){return this.queries.get(t)||{listeners:new Set,invalidated:!1,document:null,newData:null,lastRequestId:1,observableQuery:null,subscriptions:new Set}},t.prototype.setQuery=function(t,r){var o=this.getQuery(t),n=e.__assign({},o,r(o));this.queries.set(t,n)},t.prototype.invalidate=function(t,e,r){e&&this.setQuery(e,function(){return{invalidated:t}}),r&&this.setQuery(r,function(){return{invalidated:t}})},t.prototype.prepareContext=function(t){void 0===t&&(t={});var r=this.localState.prepareContext(t);return e.__assign({},r,{clientAwareness:this.clientAwareness})},t.prototype.checkInFlight=function(t){var e=this.queryStore.get(t);return e&&e.networkStatus!==exports.NetworkStatus.ready&&e.networkStatus!==exports.NetworkStatus.error},t.prototype.startPollingQuery=function(t,r,o){var n=t.pollInterval;return s.invariant(n,16),this.ssrMode||(this.pollingInfoByQueryId.set(r,{interval:n,lastPollTimeMs:Date.now()-10,options:e.__assign({},t,{fetchPolicy:"network-only"})}),o&&this.addQueryListener(r,o),this.schedulePoll(n)),r},t.prototype.stopPollingQuery=function(t){this.pollingInfoByQueryId.delete(t)},t.prototype.schedulePoll=function(t){var e=this,r=Date.now();if(this.nextPoll){if(!(t<this.nextPoll.time-r))return;clearTimeout(this.nextPoll.timeout)}this.nextPoll={time:r+t,timeout:setTimeout(function(){e.nextPoll=null;var t=1/0;e.pollingInfoByQueryId.forEach(function(r,o){if(r.interval<t&&(t=r.interval),!e.checkInFlight(o)&&Date.now()-r.lastPollTimeMs>=r.interval){var n=function(){r.lastPollTimeMs=Date.now()};e.fetchQuery(o,r.options,exports.FetchType.poll).then(n,n)}}),isFinite(t)&&e.schedulePoll(t)},t)}},t}(),q=function(){function t(t){this.cache=t}return t.prototype.getCache=function(){return this.cache},t.prototype.markQueryResult=function(t,e,o,n,s){void 0===s&&(s=!1);var i=!r.graphQLResultHasError(t);s&&r.graphQLResultHasError(t)&&t.data&&(i=!0),!n&&i&&this.cache.write({result:t.data,dataId:"ROOT_QUERY",query:e,variables:o})},t.prototype.markSubscriptionResult=function(t,e,o){r.graphQLResultHasError(t)||this.cache.write({result:t.data,dataId:"ROOT_SUBSCRIPTION",query:e,variables:o})},t.prototype.markMutationInit=function(t){var e,r=this;t.optimisticResponse&&(e="function"==typeof t.optimisticResponse?t.optimisticResponse(t.variables):t.optimisticResponse,this.cache.recordOptimisticTransaction(function(o){var n=r.cache;r.cache=o;try{r.markMutationResult({mutationId:t.mutationId,result:{data:e},document:t.document,variables:t.variables,updateQueries:t.updateQueries,update:t.update})}finally{r.cache=n}},t.mutationId))},t.prototype.markMutationResult=function(t){var e=this;if(!r.graphQLResultHasError(t.result)){var o=[];o.push({result:t.result.data,dataId:"ROOT_MUTATION",query:t.document,variables:t.variables}),t.updateQueries&&Object.keys(t.updateQueries).filter(function(e){return t.updateQueries[e]}).forEach(function(n){var s=t.updateQueries[n],i=s.query,a=s.updater,u=e.cache.diff({query:i.document,variables:i.variables,returnPartialData:!0,optimistic:!1}),c=u.result;if(u.complete){var l=r.tryFunctionOrLogError(function(){return a(c,{mutationResult:t.result,queryName:r.getOperationName(i.document)||void 0,queryVariables:i.variables})});l&&o.push({result:l,dataId:"ROOT_QUERY",query:i.document,variables:i.variables})}}),this.cache.performTransaction(function(e){o.forEach(function(t){return e.write(t)});var n=t.update;n&&r.tryFunctionOrLogError(function(){return n(e,t.result)})})}},t.prototype.markMutationComplete=function(t){var e=t.mutationId;t.optimisticResponse&&this.cache.removeOptimistic(e)},t.prototype.markUpdateQueryResult=function(t,e,r){this.cache.write({result:r,dataId:"ROOT_QUERY",variables:e,query:t})},t.prototype.reset=function(){return this.cache.reset()},t}(),R="2.6.0-beta.4",E=!1,_=function(){function t(t){var e=this;this.defaultOptions={},this.resetStoreCallbacks=[],this.clearStoreCallbacks=[];var r=t.cache,n=t.ssrMode,i=void 0!==n&&n,a=t.ssrForceFetchDelay,u=void 0===a?0:a,c=t.connectToDevTools,l=t.queryDeduplication,h=void 0===l||l,p=t.defaultOptions,f=t.assumeImmutableResults,y=void 0!==f&&f,d=t.resolvers,v=t.typeDefs,b=t.fragmentMatcher,m=t.name,Q=t.version,w=t.link;if(!w&&d&&(w=o.ApolloLink.empty()),!w||!r)throw new s.InvariantError(1);this.link=w,this.cache=r,this.store=new q(r),this.disableNetworkFetches=i||u>0,this.queryDeduplication=h,this.defaultOptions=p||{},this.typeDefs=v,u&&setTimeout(function(){return e.disableNetworkFetches=!1},u),this.watchQuery=this.watchQuery.bind(this),this.query=this.query.bind(this),this.mutate=this.mutate.bind(this),this.resetStore=this.resetStore.bind(this),this.reFetchObservableQueries=this.reFetchObservableQueries.bind(this);void 0!==c&&(c&&"undefined"!=typeof window)&&(window.__APOLLO_CLIENT__=this),this.version=R,this.localState=new g({cache:r,client:this,resolvers:d,fragmentMatcher:b}),this.queryManager=new k({link:this.link,store:this.store,queryDeduplication:h,ssrMode:i,clientAwareness:{name:m,version:Q},localState:this.localState,assumeImmutableResults:y,onBroadcast:function(){e.devToolsHookCb&&e.devToolsHookCb({action:{},state:{queries:e.queryManager.queryStore.getStore(),mutations:e.queryManager.mutationStore.getStore()},dataWithOptimisticResults:e.cache.extract(!0)})}})}return t.prototype.stop=function(){this.queryManager&&this.queryManager.stop()},t.prototype.watchQuery=function(t){return this.defaultOptions.watchQuery&&(t=e.__assign({},this.defaultOptions.watchQuery,t)),!this.disableNetworkFetches||"network-only"!==t.fetchPolicy&&"cache-and-network"!==t.fetchPolicy||(t=e.__assign({},t,{fetchPolicy:"cache-first"})),this.queryManager.watchQuery(t)},t.prototype.query=function(t){return this.defaultOptions.query&&(t=e.__assign({},this.defaultOptions.query,t)),s.invariant("cache-and-network"!==t.fetchPolicy,2),this.disableNetworkFetches&&"network-only"===t.fetchPolicy&&(t=e.__assign({},t,{fetchPolicy:"cache-first"})),this.queryManager.query(t)},t.prototype.mutate=function(t){return this.defaultOptions.mutate&&(t=e.__assign({},this.defaultOptions.mutate,t)),this.queryManager.mutate(t)},t.prototype.subscribe=function(t){return this.queryManager.startGraphQLSubscription(t)},t.prototype.readQuery=function(t,e){return void 0===e&&(e=!1),this.cache.readQuery(t,e)},t.prototype.readFragment=function(t,e){return void 0===e&&(e=!1),this.cache.readFragment(t,e)},t.prototype.writeQuery=function(t){var e=this.cache.writeQuery(t);return this.queryManager.broadcastQueries(),e},t.prototype.writeFragment=function(t){var e=this.cache.writeFragment(t);return this.queryManager.broadcastQueries(),e},t.prototype.writeData=function(t){var e=this.cache.writeData(t);return this.queryManager.broadcastQueries(),e},t.prototype.__actionHookForDevTools=function(t){this.devToolsHookCb=t},t.prototype.__requestRaw=function(t){return o.execute(this.link,t)},t.prototype.initQueryManager=function(){return this.queryManager},t.prototype.resetStore=function(){var t=this;return Promise.resolve().then(function(){return t.queryManager.clearStore()}).then(function(){return Promise.all(t.resetStoreCallbacks.map(function(t){return t()}))}).then(function(){return t.reFetchObservableQueries()})},t.prototype.clearStore=function(){var t=this;return Promise.resolve().then(function(){return Promise.all(t.clearStoreCallbacks.map(function(t){return t()}))}).then(function(){return t.queryManager.clearStore()})},t.prototype.onResetStore=function(t){var e=this;return this.resetStoreCallbacks.push(t),function(){e.resetStoreCallbacks=e.resetStoreCallbacks.filter(function(e){return e!==t})}},t.prototype.onClearStore=function(t){var e=this;return this.clearStoreCallbacks.push(t),function(){e.clearStoreCallbacks=e.clearStoreCallbacks.filter(function(e){return e!==t})}},t.prototype.reFetchObservableQueries=function(t){return this.queryManager.reFetchObservableQueries(t)},t.prototype.extract=function(t){return this.cache.extract(t)},t.prototype.restore=function(t){return this.cache.restore(t)},t.prototype.addResolvers=function(t){this.localState.addResolvers(t)},t.prototype.setResolvers=function(t){this.localState.setResolvers(t)},t.prototype.getResolvers=function(){return this.localState.getResolvers()},t.prototype.setLocalStateFragmentMatcher=function(t){this.localState.setFragmentMatcher(t)},t}();exports.ApolloClient=_,exports.ApolloError=h,exports.ObservableQuery=f,exports.default=_,exports.isApolloError=c;

@@ -66,3 +66,3 @@ import { GraphQLError } from 'graphql';

setVariables(variables: TVariables, tryFetch?: boolean, fetchResults?: boolean): Promise<ApolloQueryResult<TData> | void>;
updateQuery(mapFn: (previousQueryResult: TData, options: UpdateQueryOptions<TVariables>) => TData): void;
updateQuery<TVars = TVariables>(mapFn: (previousQueryResult: TData, options: UpdateQueryOptions<TVars>) => TData): void;
stopPolling(): void;

@@ -69,0 +69,0 @@ startPolling(pollInterval: number): void;

@@ -176,6 +176,7 @@ "use strict";

next: function (subscriptionData) {
if (options.updateQuery) {
var updateQuery = options.updateQuery;
if (updateQuery) {
_this.updateQuery(function (previous, _a) {
var variables = _a.variables;
return options.updateQuery(previous, {
return updateQuery(previous, {
subscriptionData: subscriptionData,

@@ -182,0 +183,0 @@ variables: variables,

@@ -83,5 +83,5 @@ import { ApolloLink, FetchResult } from 'apollo-link';

};
getQueryWithPreviousResult<T>(queryIdOrObservable: string | ObservableQuery<T>): {
getQueryWithPreviousResult<TData, TVariables = OperationVariables>(queryIdOrObservable: string | ObservableQuery<TData, TVariables>): {
previousResult: any;
variables: OperationVariables | undefined;
variables: TVariables | undefined;
document: DocumentNode;

@@ -88,0 +88,0 @@ };

{
"name": "apollo-client",
"version": "2.6.0-beta.3",
"version": "2.6.0-beta.4",
"description": "A simple yet functional GraphQL client.",

@@ -5,0 +5,0 @@ "main": "bundle.umd.js",

@@ -1,2 +0,2 @@

export declare const version = "2.6.0-beta.3";
export declare const version = "2.6.0-beta.4";
//# sourceMappingURL=version.d.ts.map

@@ -1,1 +0,1 @@

exports.version = "2.6.0-beta.3"
exports.version = "2.6.0-beta.4"

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc