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.1 to 2.6.0-beta.2

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)},y=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 o,n=this.queryManager.getCurrentQueryResult(this),s=n.data,i=n.partial,u=this.queryManager.queryStore.get(this.queryId);if(u){var c=u.networkStatus;if(p(u,this.options.errorPolicy))return{data:void 0,loading:!1,networkStatus:c,error:new h({graphQLErrors:u.graphQLErrors,networkError:u.networkError})};u.variables&&(this.options.variables=e.__assign({},this.options.variables,u.variables)),o={data:s,loading:a(c),networkStatus:c},u.graphQLErrors&&"all"===this.options.errorPolicy&&(o.errors=u.graphQLErrors)}else{var l=this.options.fetchPolicy,y="network-only"===l||i&&"cache-only"!==l;o={data:s,loading:y,networkStatus:y?exports.NetworkStatus.loading:exports.NetworkStatus.ready}}return i||(this.lastResult=e.__assign({},o,{stale:!1}),this.lastResultSnapshot=this.queryManager.assumeImmutableResults?this.lastResult:r.cloneDeep(this.lastResult)),e.__assign({},o,{partial:i})},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.getQueryWithPreviousResult(this.queryId),o=e.previousResult,n=e.variables,s=e.document,i=r.tryFunctionOrLogError(function(){return t(o,{variables:n})});i&&(this.queryManager.dataStore.markUpdateQueryResult(s,n,i),this.queryManager.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.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;this.shouldSubscribe&&this.queryManager.addObservableQuery(this.queryId,this),this.options.pollInterval&&(d(this),this.queryManager.startPollingQuery(this.options,this.queryId));var e={next:function(e){t.lastResult=e,t.lastResultSnapshot=t.queryManager.assumeImmutableResults?e:r.cloneDeep(e),f(t.observers,"next",e)},error:function(e){t.lastError=e,f(t.observers,"error",e)}};this.queryManager.startQuery(this.queryId,this.options,this.queryManager.queryListenerForObserver(this.queryId,this.options,e))},o.prototype.tearDownQuery=function(){this.isTornDown=!0,this.queryManager.stopPollingQuery(this.queryId),this.subscriptions.forEach(function(t){return t.unsubscribe()}),this.subscriptions.clear(),this.queryManager.removeObservableQuery(this.queryId),this.queryManager.stopQuery(this.queryId),this.observers.clear()},o}(u);function f(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,y,f,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",f=(y=this).cache,d=y.client,v={fragmentMap:l,context:e.__assign({},n,{cache:f,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,y,f=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])&&(y=p[u?i:a])&&(l=Promise.resolve(y(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)?f.resolveSubSelectedArray(t,e,n):t.selectionSet?f.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,q=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,y=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=!!y}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,y=t.update,f=t.errorPolicy,d=void 0===f?"none":f,v=t.fetchPolicy,b=t.context,m=void 0===b?{}:b;return e.__awaiter(this,void 0,void 0,function(){var t,u,l,f=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&&f.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:f.queryStore.get(r)})}}),t},this.mutationStore.initMutation(t,o,n),this.dataStore.markMutationInit({mutationId:t,document:o,variables:n,updateQueries:u(),update:y,optimisticResponse:i}),this.broadcastQueries(),l=this,[2,new Promise(function(s,a){var f,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:y}),f=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(f));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&&f&&r.graphQLResultHasError(f)&&delete f.errors,s(f)})}}})})]}})})},t.prototype.fetchQuery=function(t,o,n,s){return e.__awaiter(this,void 0,void 0,function(){var i,a,u,l,p,y,f,d,v,b,m,g,Q,w,S,q,k,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,y=void 0===p?{}:p,f=this.transform(o.query).document,d=this.getVariables(f,o.variables),this.transform(f).hasClientExports?[4,this.localState.addExportedVariables(f,d,y)]:[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:f,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"],f)&&(w=!0),S=this.idCounter++,q=this.updateQueryWatch(t,f,o),this.setQuery(t,function(){return{document:f,lastRequestId:S,invalidated:!0,cancel:q}}),this.invalidate(!0,s),this.queryStore.initQuery({queryId:t,document:f,storePreviousVariables:w,variables:d,isPoll:n===exports.FetchType.poll,isRefetch:n===exports.FetchType.refetch,metadata:a,fetchMoreForQueryId:s}),this.broadcastQueries(),(!w||"cache-and-network"===l)&&(this.queryStore.markQueryResultClient(t,!w),this.invalidate(!0,t,s),this.broadcastQueries(this.localState.shouldForceResolvers(f))),w){if(k=this.fetchRequest({requestId:S,queryId:t,document:f,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,k];k.catch(function(){})}return[2,Promise.resolve({data:v})]}})})},t.prototype.queryListenerForObserver=function(t,r,o){var n=this,s=!1;return function(i,u,c){return e.__awaiter(n,void 0,void 0,function(){var n,l,p,y,f,d,v,b,m,g,Q,w,S,q,k,R,E,_,M,x;return e.__generator(this,function(I){switch(I.label){case 0:if(this.invalidate(!1,t),!i)return[2];if(n=this.getQuery(t).observableQuery,"standby"===(l=n?n.options.fetchPolicy:r.fetchPolicy))return[2];if(p=n?n.options.errorPolicy:r.errorPolicy,y=n?n.getLastResult():null,f=n?n.getLastError():null,d=!u&&null!=i.previousVariables||"cache-only"===l||"cache-and-network"===l,v=Boolean(y&&i.networkStatus!==y.networkStatus),b=p&&(f&&f.graphQLErrors)!==i.graphQLErrors&&"none"!==p,!(!a(i.networkStatus)||v&&r.notifyOnNetworkStatusChange||d))return[3,8];if((!p||"none"===p)&&i.graphQLErrors&&i.graphQLErrors.length>0||i.networkError){if(m=new h({graphQLErrors:i.graphQLErrors,networkError:i.networkError}),s=!0,o.error)try{o.error(m)}catch(t){setTimeout(function(){throw t},0)}else setTimeout(function(){throw m},0);return[2]}I.label=1;case 1:if(I.trys.push([1,7,,8]),g=void 0,Q=void 0,u?("no-cache"!==l&&"network-only"!==l&&this.setQuery(t,function(){return{newData:null}}),g=u.result,Q=!u.complete||!1):y&&y.data&&!b?(g=y.data,Q=!1):(w=this.getQuery(t).document,S=this.dataStore.getCache().diff({query:w,variables:i.previousVariables||i.variables,optimistic:!0}),g=S.result,Q=!S.complete),q=void 0,q=Q&&"cache-only"!==l?{data:y&&y.data,loading:a(i.networkStatus),networkStatus:i.networkStatus,stale:!0}:{data:g,loading:a(i.networkStatus),networkStatus:i.networkStatus,stale:!1},"all"===p&&i.graphQLErrors&&i.graphQLErrors.length>0&&(q.errors=i.graphQLErrors),!o.next)return[3,6];if(!s&&n&&!n.isDifferentFromLastResult(q))return[3,6];I.label=2;case 2:return I.trys.push([2,5,,6]),c?(k=r.query,R=r.variables,E=r.context,[4,this.localState.runResolvers({document:k,remoteResult:q,context:E,variables:R,onlyRunForcedResolvers:c})]):[3,4];case 3:_=I.sent(),q=e.__assign({},q,_),I.label=4;case 4:return o.next(q),[3,6];case 5:return M=I.sent(),setTimeout(function(){throw M},0),[3,6];case 6:return s=!1,[3,8];case 7:return x=I.sent(),s=!0,o.error&&o.error(new h({networkError:x})),[2];case 8:return[2]}})})}},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),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 y({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.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(t){var e=this;void 0===t&&(t=!1),this.onBroadcast(),this.queries.forEach(function(r,o){r.invalidated&&r.listeners.forEach(function(n){n&&n(e.queryStore.get(o),r.newData,t)})})},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,y={query:l,variables:s,operationName:r.getOperationName(l)||void 0,context:this.prepareContext(e.__assign({},n,{forceFetch:!i}))};if(n=y.context,i){var f=h.get(l)||new Map;h.set(l,f);var d=JSON.stringify(s);if(!(a=f.get(d))){f.set(d,a=Q(o.execute(p,y)));var v=function(){f.delete(d),f.size||h.delete(l),b.unsubscribe()},b=a.subscribe({next:v,error:v,complete:v})}}else a=Q(o.execute(p,y))}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,y=a.fetchPolicy;return new Promise(function(t,l){var f=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=f.map(function(t){if(n>=o.getQuery(s).lastRequestId&&("no-cache"!==y?o.dataStore.markQueryResult(t,i,c,u,"ignore"===p||"all"===p):o.setQuery(s,function(){return{newData:{result:t.data,complete:!0}}}),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"===y)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}(),k=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.1",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,y=t.assumeImmutableResults,f=void 0!==y&&y,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 k(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 q({link:this.link,store:this.store,queryDeduplication:h,ssrMode:i,clientAwareness:{name:m,version:Q},localState:this.localState,assumeImmutableResults:f,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=y,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)},y=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(1)):("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,2);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.getQueryWithPreviousResult(this.queryId),o=e.previousResult,n=e.variables,s=e.document,i=r.tryFunctionOrLogError(function(){return t(o,{variables:n})});i&&(this.queryManager.dataStore.markUpdateQueryResult(s,n,i),this.queryManager.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;this.shouldSubscribe&&this.queryManager.addObservableQuery(this.queryId,this),this.options.pollInterval&&(d(this),this.queryManager.startPollingQuery(this.options,this.queryId));var o={next:function(o){return e.__awaiter(t,void 0,void 0,function(){var t,n,s,i,a,u,c,l,h;return e.__generator(this,function(e){switch(e.label){case 0:return t=this.queryManager,n=this.options,s=n.query,i=n.variables,a=n.fetchPolicy,u=this.variables,c=this.updateLastResult(o),t.transform(s).hasClientExports?(l=this,h=this.options,[4,t.getLocalState().addExportedVariables(s,i)]):[3,2];case 1:if(l.variables=h.variables=e.sent(),!o.loading&&c&&"cache-only"!==a&&t.transform(s).serverQuery&&!r.isEqual(u,this.variables))return[2,this.refetch()];e.label=2;case 2:return f(this.observers,"next",o),[2]}})})},error:function(e){t.lastError=e,f(t.observers,"error",e)}};this.queryManager.startQuery(this.queryId,this.options,this.queryManager.queryListenerForObserver(this.queryId,this.options,o))},o.prototype.tearDownQuery=function(){this.isTornDown=!0,this.queryManager.stopPollingQuery(this.queryId),this.subscriptions.forEach(function(t){return t.unsubscribe()}),this.subscriptions.clear(),this.queryManager.removeObservableQuery(this.queryId),this.queryManager.stopQuery(this.queryId),this.observers.clear()},o}(u);function f(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,3)}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,y,f,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",f=(y=this).cache,d=y.client,v={fragmentMap:l,context:e.__assign({},n,{cache:f,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,y,f=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])&&(y=p[u?i:a])&&(l=Promise.resolve(y(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)?f.resolveSubSelectedArray(t,e,n):t.selectionSet?f.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,q=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,y=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=!!y}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,y=t.update,f=t.errorPolicy,d=void 0===f?"none":f,v=t.fetchPolicy,b=t.context,m=void 0===b?{}:b;return e.__awaiter(this,void 0,void 0,function(){var t,u,l,f=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&&f.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:f.queryStore.get(r)})}}),t},this.mutationStore.initMutation(t,o,n),this.dataStore.markMutationInit({mutationId:t,document:o,variables:n,updateQueries:u(),update:y,optimisticResponse:i}),this.broadcastQueries(),l=this,[2,new Promise(function(s,a){var f,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:y}),f=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(f));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&&f&&r.graphQLResultHasError(f)&&delete f.errors,s(f)})}}})})]}})})},t.prototype.fetchQuery=function(t,o,n,s){return e.__awaiter(this,void 0,void 0,function(){var i,a,u,l,p,y,f,d,v,b,m,g,Q,w,S,q,k,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,y=void 0===p?{}:p,f=this.transform(o.query).document,d=this.getVariables(f,o.variables),this.transform(f).hasClientExports?[4,this.localState.addExportedVariables(f,d,y)]:[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:f,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"],f)&&(w=!0),S=this.idCounter++,q=this.updateQueryWatch(t,f,o),this.setQuery(t,function(){return{document:f,lastRequestId:S,invalidated:!0,cancel:q}}),this.invalidate(!0,s),this.queryStore.initQuery({queryId:t,document:f,storePreviousVariables:w,variables:d,isPoll:n===exports.FetchType.poll,isRefetch:n===exports.FetchType.refetch,metadata:a,fetchMoreForQueryId:s}),this.broadcastQueries(),w){if(k=this.fetchRequest({requestId:S,queryId:t,document:f,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,k];k.catch(function(){})}return this.queryStore.markQueryResultClient(t,!w),this.invalidate(!0,t,s),this.transform(f).hasForcedResolvers?[2,this.localState.runResolvers({document:f,remoteResult:{data:v},context:y,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,r,o){var n=this,s=!1;return function(i,u){return e.__awaiter(n,void 0,void 0,function(){var n,c,l,p,y,f,d,v,b,m,g,Q,w,S;return e.__generator(this,function(e){if(this.invalidate(!1,t),!i)return[2];if(n=this.getQuery(t).observableQuery,"standby"===(c=n?n.options.fetchPolicy:r.fetchPolicy))return[2];if(l=n?n.options.errorPolicy:r.errorPolicy,p=n?n.getLastResult():null,y=n?n.getLastError():null,f=!u&&null!=i.previousVariables||"cache-only"===c||"cache-and-network"===c,d=Boolean(p&&i.networkStatus!==p.networkStatus),v=l&&(y&&y.graphQLErrors)!==i.graphQLErrors&&"none"!==l,!a(i.networkStatus)||d&&r.notifyOnNetworkStatusChange||f){if((!l||"none"===l)&&i.graphQLErrors&&i.graphQLErrors.length>0||i.networkError){if(b=new h({graphQLErrors:i.graphQLErrors,networkError:i.networkError}),s=!0,o.error)try{o.error(b)}catch(t){setTimeout(function(){throw t},0)}else setTimeout(function(){throw b},0);return[2]}try{if(m=void 0,g=void 0,u?("no-cache"!==c&&"network-only"!==c&&this.setQuery(t,function(){return{newData:null}}),m=u.result,g=!u.complete||!1):p&&p.data&&!v?(m=p.data,g=!1):(Q=this.getQuery(t).document,w=this.dataStore.getCache().diff({query:Q,variables:i.previousVariables||i.variables,optimistic:!0}),m=w.result,g=!w.complete),S=void 0,S=g&&"cache-only"!==c?{data:p&&p.data,loading:a(i.networkStatus),networkStatus:i.networkStatus,stale:!0}:{data:m,loading:a(i.networkStatus),networkStatus:i.networkStatus,stale:!1},"all"===l&&i.graphQLErrors&&i.graphQLErrors.length>0&&(S.errors=i.graphQLErrors),o.next&&(s||!n||n.isDifferentFromLastResult(S)))try{o.next(S)}catch(t){setTimeout(function(){throw t},0)}s=!1}catch(t){return s=!0,o.error&&o.error(new h({networkError:t})),[2]}}return[2]})})}},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 y({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.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,y={query:l,variables:s,operationName:r.getOperationName(l)||void 0,context:this.prepareContext(e.__assign({},n,{forceFetch:!i}))};if(n=y.context,i){var f=h.get(l)||new Map;h.set(l,f);var d=JSON.stringify(s);if(!(a=f.get(d))){f.set(d,a=Q(o.execute(p,y)));var v=function(){f.delete(d),f.size||h.delete(l),b.unsubscribe()},b=a.subscribe({next:v,error:v,complete:v})}}else a=Q(o.execute(p,y))}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,y=a.fetchPolicy;return new Promise(function(t,l){var f=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=f.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"===y)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}(),k=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.2",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,y=t.assumeImmutableResults,f=void 0!==y&&y,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(4);this.link=w,this.cache=r,this.store=new k(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 q({link:this.link,store:this.store,queryDeduplication:h,ssrMode:i,clientAwareness:{name:m,version:Q},localState:this.localState,assumeImmutableResults:f,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,5),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=y,exports.default=_,exports.isApolloError=c;

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

startPolling(pollInterval: number): void;
private updateLastResult;
private onSubscribe;

@@ -71,0 +72,0 @@ private setUpQuery;

@@ -91,2 +91,3 @@ "use strict";

this.options.variables = tslib_1.__assign({}, this.options.variables, queryStoreValue.variables);
this.variables = this.options.variables;
}

@@ -113,6 +114,3 @@ result = {

if (!partial) {
this.lastResult = tslib_1.__assign({}, result, { stale: false });
this.lastResultSnapshot = this.queryManager.assumeImmutableResults
? this.lastResult
: apollo_utilities_1.cloneDeep(this.lastResult);
this.updateLastResult(tslib_1.__assign({}, result, { stale: false }));
}

@@ -254,2 +252,10 @@ return tslib_1.__assign({}, result, { partial: partial });

};
ObservableQuery.prototype.updateLastResult = function (newResult) {
var previousResult = this.lastResult;
this.lastResult = newResult;
this.lastResultSnapshot = this.queryManager.assumeImmutableResults
? newResult
: apollo_utilities_1.cloneDeep(newResult);
return previousResult;
};
ObservableQuery.prototype.onSubscribe = function (observer) {

@@ -281,9 +287,31 @@ var _this = this;

var observer = {
next: function (result) {
_this.lastResult = result;
_this.lastResultSnapshot = _this.queryManager.assumeImmutableResults
? result
: apollo_utilities_1.cloneDeep(result);
iterateObserversSafely(_this.observers, 'next', result);
},
next: function (result) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
var queryManager, _a, query, variables, fetchPolicy, lastVariables, previousResult, _b, _c;
return tslib_1.__generator(this, function (_d) {
switch (_d.label) {
case 0:
queryManager = this.queryManager;
_a = this.options, query = _a.query, variables = _a.variables, fetchPolicy = _a.fetchPolicy;
lastVariables = this.variables;
previousResult = this.updateLastResult(result);
if (!queryManager.transform(query).hasClientExports) return [3, 2];
_b = this;
_c = this.options;
return [4, queryManager.getLocalState().addExportedVariables(query, variables)];
case 1:
_b.variables = _c.variables = (_d.sent());
if (!result.loading &&
previousResult &&
fetchPolicy !== 'cache-only' &&
queryManager.transform(query).serverQuery &&
!apollo_utilities_1.isEqual(lastVariables, this.variables)) {
return [2, this.refetch()];
}
_d.label = 2;
case 2:
iterateObserversSafely(this.observers, 'next', result);
return [2];
}
});
}); },
error: function (error) {

@@ -290,0 +318,0 @@ _this.lastError = error;

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

fetchQuery<T>(queryId: string, options: WatchQueryOptions, fetchType?: FetchType, fetchMoreForQueryId?: string): Promise<FetchResult<T>>;
private markQueryResult;
queryListenerForObserver<T>(queryId: string, options: WatchQueryOptions, observer: Observer<ApolloQueryResult<T>>): QueryListener;
private transformCache;
private transform;
transform(document: DocumentNode): Readonly<{
document: Readonly<DocumentNode>;
hasClientExports: boolean;
hasForcedResolvers: boolean;
clientQuery: Readonly<DocumentNode> | null;
serverQuery: Readonly<DocumentNode> | null;
defaultVars: Readonly<OperationVariables>;
}>;
private getVariables;

@@ -80,3 +88,3 @@ watchQuery<T, TVariables = OperationVariables>(options: WatchQueryOptions, shouldSubscribe?: boolean): ObservableQuery<T, TVariables>;

};
broadcastQueries(forceResolvers?: boolean): void;
broadcastQueries(): void;
getLocalState(): LocalState<TStore>;

@@ -83,0 +91,0 @@ private inFlightLinkObservables;

@@ -191,3 +191,3 @@ "use strict";

return tslib_1.__awaiter(this, void 0, void 0, function () {
var _a, metadata, _b, fetchPolicy, _c, context, query, variables, storeResult, needToFetch, _d, complete, result, shouldFetch, requestId, cancel, shouldDispatchClientResult, networkResult;
var _a, metadata, _b, fetchPolicy, _c, context, query, variables, storeResult, needToFetch, _d, complete, result, shouldFetch, requestId, cancel, networkResult;
var _this = this;

@@ -243,8 +243,2 @@ return tslib_1.__generator(this, function (_e) {

this.broadcastQueries();
shouldDispatchClientResult = !shouldFetch || fetchPolicy === 'cache-and-network';
if (shouldDispatchClientResult) {
this.queryStore.markQueryResultClient(queryId, !shouldFetch);
this.invalidate(true, queryId, fetchMoreForQueryId);
this.broadcastQueries(this.localState.shouldForceResolvers(query));
}
if (shouldFetch) {

@@ -273,7 +267,21 @@ networkResult = this.fetchRequest({

}
else {
networkResult.catch(function () { });
}
networkResult.catch(function () { });
}
return [2, Promise.resolve({ data: storeResult })];
this.queryStore.markQueryResultClient(queryId, !shouldFetch);
this.invalidate(true, queryId, fetchMoreForQueryId);
if (this.transform(query).hasForcedResolvers) {
return [2, this.localState.runResolvers({
document: query,
remoteResult: { data: storeResult },
context: context,
variables: variables,
onlyRunForcedResolvers: true,
}).then(function (result) {
_this.markQueryResult(queryId, result, options, fetchMoreForQueryId);
_this.broadcastQueries();
return result;
})];
}
this.broadcastQueries();
return [2, { data: storeResult }];
}

@@ -283,72 +291,79 @@ });

};
QueryManager.prototype.markQueryResult = function (queryId, result, _a, fetchMoreForQueryId) {
var fetchPolicy = _a.fetchPolicy, variables = _a.variables, errorPolicy = _a.errorPolicy;
if (fetchPolicy === 'no-cache') {
this.setQuery(queryId, function () { return ({
newData: { result: result.data, complete: true },
}); });
}
else {
this.dataStore.markQueryResult(result, this.getQuery(queryId).document, variables, fetchMoreForQueryId, errorPolicy === 'ignore' || errorPolicy === 'all');
}
};
QueryManager.prototype.queryListenerForObserver = function (queryId, options, observer) {
var _this = this;
var previouslyHadError = false;
return function (queryStoreValue, newData, forceResolvers) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
var observableQuery, fetchPolicy, errorPolicy, lastResult, lastError, shouldNotifyIfLoading, networkStatusChanged, errorStatusChanged, apolloError_1, data, isMissing, document_1, readResult, resultFromStore, query, variables, context, updatedResult, e_1, error_1;
return function (queryStoreValue, newData) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
var observableQuery, fetchPolicy, errorPolicy, lastResult, lastError, shouldNotifyIfLoading, networkStatusChanged, errorStatusChanged, apolloError_1, data, isMissing, document_1, readResult, resultFromStore;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0:
this.invalidate(false, queryId);
if (!queryStoreValue)
return [2];
observableQuery = this.getQuery(queryId).observableQuery;
fetchPolicy = observableQuery
? observableQuery.options.fetchPolicy
: options.fetchPolicy;
if (fetchPolicy === 'standby')
return [2];
errorPolicy = observableQuery
? observableQuery.options.errorPolicy
: options.errorPolicy;
lastResult = observableQuery
? observableQuery.getLastResult()
: null;
lastError = observableQuery ? observableQuery.getLastError() : null;
shouldNotifyIfLoading = (!newData && queryStoreValue.previousVariables != null) ||
fetchPolicy === 'cache-only' ||
fetchPolicy === 'cache-and-network';
networkStatusChanged = Boolean(lastResult &&
queryStoreValue.networkStatus !== lastResult.networkStatus);
errorStatusChanged = errorPolicy &&
(lastError && lastError.graphQLErrors) !==
queryStoreValue.graphQLErrors &&
errorPolicy !== 'none';
if (!(!networkStatus_1.isNetworkRequestInFlight(queryStoreValue.networkStatus) ||
(networkStatusChanged && options.notifyOnNetworkStatusChange) ||
shouldNotifyIfLoading)) return [3, 8];
if (((!errorPolicy || errorPolicy === 'none') &&
queryStoreValue.graphQLErrors &&
queryStoreValue.graphQLErrors.length > 0) ||
queryStoreValue.networkError) {
apolloError_1 = new ApolloError_1.ApolloError({
graphQLErrors: queryStoreValue.graphQLErrors,
networkError: queryStoreValue.networkError,
});
previouslyHadError = true;
if (observer.error) {
try {
observer.error(apolloError_1);
}
catch (e) {
setTimeout(function () {
throw e;
}, 0);
}
this.invalidate(false, queryId);
if (!queryStoreValue)
return [2];
observableQuery = this.getQuery(queryId).observableQuery;
fetchPolicy = observableQuery
? observableQuery.options.fetchPolicy
: options.fetchPolicy;
if (fetchPolicy === 'standby')
return [2];
errorPolicy = observableQuery
? observableQuery.options.errorPolicy
: options.errorPolicy;
lastResult = observableQuery
? observableQuery.getLastResult()
: null;
lastError = observableQuery ? observableQuery.getLastError() : null;
shouldNotifyIfLoading = (!newData && queryStoreValue.previousVariables != null) ||
fetchPolicy === 'cache-only' ||
fetchPolicy === 'cache-and-network';
networkStatusChanged = Boolean(lastResult &&
queryStoreValue.networkStatus !== lastResult.networkStatus);
errorStatusChanged = errorPolicy &&
(lastError && lastError.graphQLErrors) !==
queryStoreValue.graphQLErrors &&
errorPolicy !== 'none';
if (!networkStatus_1.isNetworkRequestInFlight(queryStoreValue.networkStatus) ||
(networkStatusChanged && options.notifyOnNetworkStatusChange) ||
shouldNotifyIfLoading) {
if (((!errorPolicy || errorPolicy === 'none') &&
queryStoreValue.graphQLErrors &&
queryStoreValue.graphQLErrors.length > 0) ||
queryStoreValue.networkError) {
apolloError_1 = new ApolloError_1.ApolloError({
graphQLErrors: queryStoreValue.graphQLErrors,
networkError: queryStoreValue.networkError,
});
previouslyHadError = true;
if (observer.error) {
try {
observer.error(apolloError_1);
}
else {
catch (e) {
setTimeout(function () {
throw apolloError_1;
throw e;
}, 0);
if (process.env.NODE_ENV !== 'production') {
console.info('An unhandled error was thrown because no error handler is registered ' +
'for the query ' +
JSON.stringify(queryStoreValue.document));
}
}
return [2];
}
_a.label = 1;
case 1:
_a.trys.push([1, 7, , 8]);
else {
setTimeout(function () {
throw apolloError_1;
}, 0);
if (process.env.NODE_ENV !== 'production') {
console.info('An unhandled error was thrown because no error handler is registered ' +
'for the query ' +
JSON.stringify(queryStoreValue.document));
}
}
return [2];
}
try {
data = void 0;

@@ -402,42 +417,26 @@ isMissing = void 0;

}
if (!observer.next) return [3, 6];
if (!(previouslyHadError ||
!observableQuery ||
observableQuery.isDifferentFromLastResult(resultFromStore))) return [3, 6];
_a.label = 2;
case 2:
_a.trys.push([2, 5, , 6]);
if (!forceResolvers) return [3, 4];
query = options.query, variables = options.variables, context = options.context;
return [4, this.localState.runResolvers({
document: query,
remoteResult: resultFromStore,
context: context,
variables: variables,
onlyRunForcedResolvers: forceResolvers,
})];
case 3:
updatedResult = _a.sent();
resultFromStore = tslib_1.__assign({}, resultFromStore, updatedResult);
_a.label = 4;
case 4:
observer.next(resultFromStore);
return [3, 6];
case 5:
e_1 = _a.sent();
setTimeout(function () {
throw e_1;
}, 0);
return [3, 6];
case 6:
if (observer.next) {
if (previouslyHadError ||
!observableQuery ||
observableQuery.isDifferentFromLastResult(resultFromStore)) {
try {
observer.next(resultFromStore);
}
catch (e) {
setTimeout(function () {
throw e;
}, 0);
}
}
}
previouslyHadError = false;
return [3, 8];
case 7:
error_1 = _a.sent();
}
catch (error) {
previouslyHadError = true;
if (observer.error)
observer.error(new ApolloError_1.ApolloError({ networkError: error_1 }));
observer.error(new ApolloError_1.ApolloError({ networkError: error }));
return [2];
case 8: return [2];
}
}
return [2];
});

@@ -457,2 +456,3 @@ }); };

hasClientExports: apollo_utilities_1.hasClientExports(transformed),
hasForcedResolvers: this.localState.shouldForceResolvers(transformed),
clientQuery: clientQuery,

@@ -696,5 +696,4 @@ serverQuery: serverQuery,

};
QueryManager.prototype.broadcastQueries = function (forceResolvers) {
QueryManager.prototype.broadcastQueries = function () {
var _this = this;
if (forceResolvers === void 0) { forceResolvers = false; }
this.onBroadcast();

@@ -705,3 +704,3 @@ this.queries.forEach(function (info, id) {

if (listener) {
listener(_this.queryStore.get(id), info.newData, forceResolvers);
listener(_this.queryStore.get(id), info.newData);
}

@@ -789,10 +788,3 @@ });

if (requestId >= _this.getQuery(queryId).lastRequestId) {
if (fetchPolicy !== 'no-cache') {
_this.dataStore.markQueryResult(result, document, variables, fetchMoreForQueryId, errorPolicy === 'ignore' || errorPolicy === 'all');
}
else {
_this.setQuery(queryId, function () { return ({
newData: { result: result.data, complete: true },
}); });
}
_this.markQueryResult(queryId, result, options, fetchMoreForQueryId);
_this.queryStore.markQueryResult(queryId, result, fetchMoreForQueryId);

@@ -799,0 +791,0 @@ _this.invalidate(true, queryId, fetchMoreForQueryId);

{
"name": "apollo-client",
"version": "2.6.0-beta.1",
"version": "2.6.0-beta.2",
"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.1";
export declare const version = "2.6.0-beta.2";
//# sourceMappingURL=version.d.ts.map

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

exports.version = "2.6.0-beta.1"
exports.version = "2.6.0-beta.2"

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