apollo-client
Advanced tools
Comparing version 2.6.0-rc.2 to 2.6.0-rc.3
@@ -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 Array.isArray(t)&&t.length>0}function l(t){return t.hasOwnProperty("graphQLErrors")}var h=function(t){var e="";return c(t.graphQLErrors)&&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$/,"")},p=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||h(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 y=function(t,e){return void 0===e&&(e="none"),t&&(t.networkError||"none"===e&&c(t.graphQLErrors))},f=function(t){function o(e){var o=e.queryManager,n=e.options,s=e.shouldSubscribe,i=void 0===s||s,a=t.call(this,function(t){return a.onSubscribe(t)})||this;a.observers=new Set,a.subscriptions=new Set,a.isTornDown=!1,a.options=n,a.variables=n.variables||{},a.queryId=o.generateQueryId(),a.shouldSubscribe=i;var u=r.getOperationDefinition(n.query);return a.queryName=u&&u.name&&u.name.value,a.queryManager=o,a}return e.__extends(o,t),o.prototype.result=function(){var t=this;return new Promise(function(e,r){var o={next:function(r){e(r),t.observers.delete(o),t.observers.size||t.queryManager.removeQuery(t.queryId),setTimeout(function(){n.unsubscribe()},0)},error:r},n=t.subscribe(o)})},o.prototype.currentResult=function(){var t=this.getCurrentResult();return void 0===t.data&&(t.data={}),t},o.prototype.getCurrentResult=function(){if(this.isTornDown){var t=this.lastResult;return{data:!this.lastError&&t&&t.data||void 0,error:this.lastError,loading:!1,networkStatus:exports.NetworkStatus.error}}var r,o=this.queryManager.getCurrentQueryResult(this),n=o.data,s=o.partial,i=this.queryManager.queryStore.get(this.queryId),u=this.options.fetchPolicy,c="network-only"===u||"no-cache"===u;if(i){var l=i.networkStatus;if(y(i,this.options.errorPolicy))return{data:void 0,loading:!1,networkStatus:l,error:new p({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(l),networkStatus:l},i.graphQLErrors&&"all"===this.options.errorPolicy&&(r.errors=i.graphQLErrors)}else{var h=c||s&&"cache-only"!==u;r={data:n,loading:h,networkStatus:h?exports.NetworkStatus.loading:exports.NetworkStatus.ready}}return s||this.updateLastResult(e.__assign({},r,{stale:!1})),e.__assign({},r,{partial:s})},o.prototype.isDifferentFromLastResult=function(t){var e=this.lastResultSnapshot;return!(e&&t&&e.networkStatus===t.networkStatus&&e.stale===t.stale&&r.isEqual(e.data,t.data))},o.prototype.getLastResult=function(){return this.lastResult},o.prototype.getLastError=function(){return this.lastError},o.prototype.resetLastResults=function(){delete this.lastResult,delete this.lastResultSnapshot,delete this.lastError,this.isTornDown=!1},o.prototype.refetch=function(t){var o=this.options.fetchPolicy;return"cache-only"===o?Promise.reject(new s.InvariantError(3)):("no-cache"!==o&&(o="network-only"),r.isEqual(this.variables,t)||(this.variables=e.__assign({},this.variables,t)),r.isEqual(this.options.variables,this.variables)||(this.options.variables=e.__assign({},this.options.variables,this.variables)),this.queryManager.fetchQuery(this.queryId,e.__assign({},this.options,{fetchPolicy:o}),exports.FetchType.refetch))},o.prototype.fetchMore=function(t){var r=this;s.invariant(t.updateQuery,4);var o=e.__assign({},t.query?t:e.__assign({},this.options,t,{variables:e.__assign({},this.variables,t.variables)}),{fetchPolicy:"network-only"}),n=this.queryManager.generateQueryId();return this.queryManager.fetchQuery(n,o,exports.FetchType.normal,this.queryId).then(function(e){return r.updateQuery(function(r){return t.updateQuery(r,{fetchMoreResult:e.data,variables:o.variables})}),r.queryManager.stopQuery(n),e},function(t){throw r.queryManager.stopQuery(n),t})},o.prototype.subscribeToMore=function(t){var e=this,r=this.queryManager.startGraphQLSubscription({query:t.document,variables:t.variables}).subscribe({next:function(r){var o=t.updateQuery;o&&e.updateQuery(function(t,e){var n=e.variables;return o(t,{subscriptionData:r,variables:n})})},error:function(e){t.onError&&t.onError(e)}});return this.subscriptions.add(r),function(){e.subscriptions.delete(r)&&r.unsubscribe()}},o.prototype.setOptions=function(t){var r=this.options.fetchPolicy;this.options=e.__assign({},this.options,t),t.pollInterval?this.startPolling(t.pollInterval):0===t.pollInterval&&this.stopPolling();var o=t.fetchPolicy;return this.setVariables(this.options.variables,r!==o&&("cache-only"===r||"standby"===r||"network-only"===o),t.fetchResults)},o.prototype.setVariables=function(t,e,o){return void 0===e&&(e=!1),void 0===o&&(o=!0),this.isTornDown=!1,t=t||this.variables,!e&&r.isEqual(t,this.variables)?this.observers.size&&o?this.result():Promise.resolve():(this.variables=this.options.variables=t,this.observers.size?this.queryManager.fetchQuery(this.queryId,this.options):Promise.resolve())},o.prototype.updateQuery=function(t){var e=this.queryManager,o=e.getQueryWithPreviousResult(this.queryId),n=o.previousResult,s=o.variables,i=o.document,a=r.tryFunctionOrLogError(function(){return t(n,{variables:s})});a&&(e.dataStore.markUpdateQueryResult(i,s,a),e.broadcastQueries())},o.prototype.stopPolling=function(){this.queryManager.stopPollingQuery(this.queryId),this.options.pollInterval=void 0},o.prototype.startPolling=function(t){b(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;try{var r=t._subscription._observer;r&&!r.error&&(r.error=v)}catch(t){}var o=!this.observers.size;return this.observers.add(t),t.next&&this.lastResult&&t.next(this.lastResult),t.error&&this.lastError&&t.error(this.lastError),o&&this.setUpQuery(),function(){e.observers.delete(t)&&!e.observers.size&&e.tearDownQuery()}},o.prototype.setUpQuery=function(){var t=this,e=this.queryManager,o=this.queryId;this.shouldSubscribe&&e.addObservableQuery(o,this),this.options.pollInterval&&(b(this),e.startPollingQuery(this.options,o));var n=function(e){d(t.observers,"error",t.lastError=e)};e.observeQuery(o,this.options,{next:function(o){if(t.lastError||t.isDifferentFromLastResult(o)){var n=t.updateLastResult(o),s=t.options,i=s.query,a=s.variables,u=s.fetchPolicy;e.transform(i).hasClientExports?e.getLocalState().addExportedVariables(i,a).then(function(s){var a=t.variables;t.variables=t.options.variables=s,!o.loading&&n&&"cache-only"!==u&&e.transform(i).serverQuery&&!r.isEqual(a,s)?t.refetch():d(t.observers,"next",o)}):d(t.observers,"next",o)}},error:n}).catch(n)},o.prototype.tearDownQuery=function(){var t=this.queryManager;this.isTornDown=!0,t.stopPollingQuery(this.queryId),this.subscriptions.forEach(function(t){return t.unsubscribe()}),this.subscriptions.clear(),t.removeObservableQuery(this.queryId),t.stopQuery(this.queryId),this.observers.clear()},o}(u);function v(t){}function d(t,e,r){var o=[];t.forEach(function(t){return t[e]&&o.push(t)}),o.forEach(function(t){return t[e](r)})}function b(t){var e=t.options.fetchPolicy;s.invariant("cache-first"!==e&&"cache-only"!==e,5)}var m=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}(),g=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];s.invariant(!e||e.document===t.document||r.isEqual(e.document,t.document),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=c(e.errors)?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){var r=this.store&&this.store[t];r&&(r.networkError=null,r.previousVariables=null,e&&(r.networkStatus=exports.NetworkStatus.ready))},t.prototype.stopQuery=function(t){delete this.store[t]},t.prototype.reset=function(t){var e=this;Object.keys(this.store).forEach(function(r){t.indexOf(r)<0?e.stopQuery(r):e.store[r].networkStatus=exports.NetworkStatus.loading})},t}();function Q(t){return t.charAt(0).toUpperCase()+t.slice(1)}var w=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.buildRootValueFromCache=function(t,e){return this.cache.diff({query:r.buildQueryFromSelectionSet(t),variables:e,returnPartialData:!0,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,v,d;return e.__generator(this,function(b){return u=r.getMainDefinition(t),c=r.getFragmentDefinitions(t),l=r.createFragmentMap(c),h=u.operation,p=h?Q(h):"Query",f=(y=this).cache,v=y.client,d={fragmentMap:l,context:e.__assign({},n,{cache:f,client:v}),variables:s,fragmentMatcher:i,defaultOperationType:p,exportedVariables:{},onlyRunForcedResolvers:a},[2,this.resolveSelectionSet(u.selectionSet,o,d).then(function(t){return{result:t,exportedVariables:d.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.shouldForceResolvers(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 S(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 q(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 k=Object.prototype.hasOwnProperty,R=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 m,this.queryStore=new g,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.link=e,this.queryDeduplication=n,this.dataStore=s,this.onBroadcast=a,this.clientAwareness=h,this.localState=p||new w({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,l=void 0===u?[]:u,h=t.awaitRefetchQueries,y=void 0!==h&&h,f=t.update,v=t.errorPolicy,d=void 0===v?"none":v,b=t.fetchPolicy,m=t.context,g=void 0===m?{}:m;return e.__awaiter(this,void 0,void 0,function(){var t,u,h,v=this;return e.__generator(this,function(m){switch(m.label){case 0:return s.invariant(o,7),s.invariant(!b||"no-cache"===b,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,g)]:[3,2];case 1:n=m.sent(),m.label=2;case 2:return u=function(){var t={};return a&&v.queries.forEach(function(e,r){var o=e.observableQuery;if(o){var n=o.queryName;n&&k.call(a,n)&&(t[r]={updater:a[n],query:v.queryStore.get(r)})}}),t},this.mutationStore.initMutation(t,o,n),this.dataStore.markMutationInit({mutationId:t,document:o,variables:n,updateQueries:u(),update:f,optimisticResponse:i}),this.broadcastQueries(),h=this,[2,new Promise(function(s,a){var v,m;h.getObservableFromLink(o,e.__assign({},g,{optimisticResponse:i}),n,!1).subscribe({next:function(e){r.graphQLResultHasError(e)&&"none"===d?m=new p({graphQLErrors:e.errors}):(h.mutationStore.markMutationResult(t),"no-cache"!==b&&h.dataStore.markMutationResult({mutationId:t,result:e,document:o,variables:n,updateQueries:u(),update:f}),v=e)},error:function(e){h.mutationStore.markMutationError(t,e),h.dataStore.markMutationComplete({mutationId:t,optimisticResponse:i}),h.broadcastQueries(),h.setQuery(t,function(){return{document:null}}),a(new p({networkError:e}))},complete:function(){if(m&&h.mutationStore.markMutationError(t,m),h.dataStore.markMutationComplete({mutationId:t,optimisticResponse:i}),h.broadcastQueries(),m)a(m);else{"function"==typeof l&&(l=l(v));var e=[];c(l)&&l.forEach(function(t){if("string"==typeof t)h.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(h.query(r))}}),Promise.all(y?e:[]).then(function(){h.setQuery(t,function(){return{document:null}}),"ignore"===d&&v&&r.graphQLResultHasError(v)&&delete v.errors,s(v)})}}})})]}})})},t.prototype.fetchQuery=function(t,o,n,s){return e.__awaiter(this,void 0,void 0,function(){var i,a,u,c,h,y,f,v,d,b,m,g,Q,w,S,q,k,R,E=this;return e.__generator(this,function(_){switch(_.label){case 0:return i=o.metadata,a=void 0===i?null:i,u=o.fetchPolicy,c=void 0===u?"cache-first":u,h=o.context,y=void 0===h?{}:h,f=this.transform(o.query).document,v=this.getVariables(f,o.variables),this.transform(f).hasClientExports?[4,this.localState.addExportedVariables(f,v,y)]:[3,2];case 1:v=_.sent(),_.label=2;case 2:if(o=e.__assign({},o,{variables:v}),m=b="network-only"===c||"no-cache"===c,b||(g=this.dataStore.getCache().diff({query:f,variables:v,returnPartialData:!0,optimistic:!1}),Q=g.complete,w=g.result,m=!Q||"cache-and-network"===c,d=w),S=m&&"cache-only"!==c&&"standby"!==c,r.hasDirectives(["live"],f)&&(S=!0),q=this.idCounter++,k="no-cache"!==c?this.updateQueryWatch(t,f,o):void 0,this.setQuery(t,function(){return{document:f,lastRequestId:q,invalidated:!0,cancel:k}}),this.invalidate(s),this.queryStore.initQuery({queryId:t,document:f,storePreviousVariables:S,variables:v,isPoll:n===exports.FetchType.poll,isRefetch:n===exports.FetchType.refetch,metadata:a,fetchMoreForQueryId:s}),this.broadcastQueries(),S){if(R=this.fetchRequest({requestId:q,queryId:t,document:f,options:o,fetchMoreForQueryId:s}).catch(function(e){throw l(e)?e:(q>=E.getQuery(t).lastRequestId&&(E.queryStore.markQueryError(t,e,s),E.invalidate(t),E.invalidate(s),E.broadcastQueries()),new p({networkError:e}))}),"cache-and-network"!==c)return[2,R];R.catch(function(){})}return this.queryStore.markQueryResultClient(t,!S),this.invalidate(t),this.invalidate(s),this.transform(f).hasForcedResolvers?[2,this.localState.runResolvers({document:f,remoteResult:{data:d},context:y,variables:v,onlyRunForcedResolvers:!0}).then(function(e){return E.markQueryResult(t,e,o,s),E.broadcastQueries(),e})]:(this.broadcastQueries(),[2,{data:d}])}})})},t.prototype.markQueryResult=function(t,e,r,o){var n=r.fetchPolicy,s=r.variables,i=r.errorPolicy;"no-cache"===n?this.setQuery(t,function(){return{newData:{result:e.data,complete:!0}}}):this.dataStore.markQueryResult(e,this.getQuery(t).document,s,o,"ignore"===i||"all"===i)},t.prototype.queryListenerForObserver=function(t,e,r){var o=this;function n(t,e){if(r[t])try{r[t](e)}catch(t){}}return function(r,s){if(o.invalidate(t,!1),r){var i=o.getQuery(t),u=i.observableQuery,l=i.document,h=u?u.options.fetchPolicy:e.fetchPolicy;if("standby"!==h){var y=a(r.networkStatus),f=u&&u.getLastResult(),v=!(!f||f.networkStatus===r.networkStatus),d=e.returnPartialData||!s&&r.previousVariables||v&&e.notifyOnNetworkStatusChange||"cache-only"===h||"cache-and-network"===h;if(!y||d){var b=c(r.graphQLErrors),m=u&&u.options.errorPolicy||e.errorPolicy||"none";if("none"===m&&b||r.networkError)return n("error",new p({graphQLErrors:r.graphQLErrors,networkError:r.networkError}));try{var g=void 0,Q=void 0;if(s)"no-cache"!==h&&"network-only"!==h&&o.setQuery(t,function(){return{newData:null}}),g=s.result,Q=!s.complete;else{var w=u&&u.getLastError(),S="none"!==m&&(w&&w.graphQLErrors)!==r.graphQLErrors;if(f&&f.data&&!S)g=f.data,Q=!1;else{var q=o.dataStore.getCache().diff({query:l,variables:r.previousVariables||r.variables,returnPartialData:!0,optimistic:!0});g=q.result,Q=!q.complete}}var k=Q&&!(e.returnPartialData||"cache-only"===h),R={data:k?f&&f.data:g,loading:y,networkStatus:r.networkStatus,stale:k};"all"===m&&b&&(R.errors=r.graphQLErrors),n("next",R)}catch(t){n("error",new p({networkError:t}))}}}}}},t.prototype.transform=function(t){var e=this.transformCache;if(!e.has(t)){var o=this.dataStore.getCache(),n=o.transformDocument(t),s=r.removeConnectionDirectiveFromDocument(o.transformForLink(n)),i=this.localState.clientQuery(n),a=this.localState.serverQuery(s),u={document:n,hasClientExports:r.hasClientExports(n),hasForcedResolvers:this.localState.shouldForceResolvers(n),clientQuery:i,serverQuery:a,defaultVars:r.getDefaultValues(r.getOperationDefinition(n))},c=function(t){t&&!e.has(t)&&e.set(t,u)};c(t),c(n),c(i),c(a)}return e.get(t)},t.prototype.getVariables=function(t,r){return e.__assign({},this.transform(t).defaultVars,r)},t.prototype.watchQuery=function(t,r){void 0===r&&(r=!0),s.invariant("standby"!==t.fetchPolicy,9),t.variables=this.getVariables(t.query,t.variables),void 0===t.notifyOnNetworkStatusChange&&(t.notifyOnNetworkStatusChange=!1);var o=e.__assign({},t);return new f({queryManager:this,options:o,shouldSubscribe:r})},t.prototype.query=function(t){var e=this;return s.invariant(t.query,10),s.invariant("Document"===t.query.kind,11),s.invariant(!t.returnPartialData,12),s.invariant(!t.pollInterval,13),new Promise(function(r,o){var n=e.watchQuery(t,!1);e.fetchQueryRejectFns.set("query:"+n.queryId,o),n.result().then(r,o).then(function(){return e.fetchQueryRejectFns.delete("query:"+n.queryId)})})},t.prototype.generateQueryId=function(){return String(this.idCounter++)},t.prototype.stopQueryInStore=function(t){this.stopQueryInStoreNoBroadcast(t),this.broadcastQueries()},t.prototype.stopQueryInStoreNoBroadcast=function(t){this.stopPollingQuery(t),this.queryStore.stopQuery(t),this.invalidate(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(n)}}),this.broadcastQueries(),Promise.all(r)},t.prototype.observeQuery=function(t,e,r){return this.addQueryListener(t,this.queryListenerForObserver(t,e,r)),this.fetchQuery(t,e)},t.prototype.startQuery=function(t,e,r){return this.addQueryListener(t,r),this.fetchQuery(t,e).catch(function(){}),t},t.prototype.startGraphQLSubscription=function(t){var e=this,o=t.query,n=t.fetchPolicy,s=t.variables;o=this.transform(o).document,s=this.getVariables(o,s);var i=function(t){return e.getObservableFromLink(o,{},t,!1).map(function(s){if(n&&"no-cache"===n||(e.dataStore.markSubscriptionResult(s,o,t),e.broadcastQueries()),r.graphQLResultHasError(s))throw new p({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=r.returnPartialData,a=t.getLastResult(),u=this.getQuery(t.queryId).newData;if(u&&u.complete)return{data:u.result,partial:!1};if("no-cache"===s||"network-only"===s)return{data:void 0,partial:!1};var c=this.dataStore.getCache().diff({query:n,variables:o,previousResult:a?a.data:void 0,returnPartialData:!0,optimistic:e}),l=c.result,h=c.complete;return{data:h||i?l:void 0,partial:!h}},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 v=JSON.stringify(s);if(!(a=f.get(v))){f.set(v,a=S(o.execute(p,y)));var d=function(){f.delete(v),f.size||h.delete(l),b.unsubscribe()},b=a.subscribe({next:d,error:d,complete:d})}}else a=S(o.execute(p,y))}else a=u.of({data:{}}),n=this.prepareContext(n);var m=this.transform(t).clientQuery;return m&&(a=q(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,l=a.variables,h=a.errorPolicy,y=void 0===h?"none":h,f=a.fetchPolicy;return new Promise(function(t,h){var v=o.getObservableFromLink(i,a.context,l),d="fetchRequest:"+s;o.fetchQueryRejectFns.set(d,h);var b=function(){o.fetchQueryRejectFns.delete(d),o.setQuery(s,function(t){t.subscriptions.delete(m)})},m=v.map(function(t){if(n>=o.getQuery(s).lastRequestId&&(o.markQueryResult(s,t,a,u),o.queryStore.markQueryResult(s,t,u),o.invalidate(s),o.invalidate(u),o.broadcastQueries()),"none"===y&&c(t.errors))return h(new p({graphQLErrors:t.errors}));if("all"===y&&(r=t.errors),u||"no-cache"===f)e=t.data;else{var v=o.dataStore.getCache().diff({variables:l,query:i,optimistic:!1,returnPartialData:!0}),d=v.result;(v.complete||a.returnPartialData)&&(e=d)}}).subscribe({error:function(t){b(),h(t)},complete:function(){b(),t({data:e,errors:r,loading:!1,networkStatus:exports.NetworkStatus.ready,stale:!1})}});o.setQuery(s,function(t){t.subscriptions.add(m)})})},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){void 0===e&&(e=!0),t&&this.setQuery(t,function(){return{invalidated:e}})},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=this,i=t.pollInterval;if(s.invariant(i,16),!this.ssrMode){var a=this.pollingInfoByQueryId.get(r);a||this.pollingInfoByQueryId.set(r,a={}),a.interval=i,a.options=e.__assign({},t,{fetchPolicy:"network-only"});var u=function(){var t=n.pollingInfoByQueryId.get(r);t&&(n.checkInFlight(r)?c():n.fetchQuery(r,t.options,exports.FetchType.poll).then(c,c))},c=function(){var t=n.pollingInfoByQueryId.get(r);t&&(clearTimeout(t.timeout),t.timeout=setTimeout(u,t.interval))};o&&this.addQueryListener(r,o),c()}return r},t.prototype.stopPollingQuery=function(t){this.pollingInfoByQueryId.delete(t)},t}(),E=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=[{result:t.result.data,dataId:"ROOT_MUTATION",query:t.document,variables:t.variables}],n=t.updateQueries;n&&Object.keys(n).forEach(function(s){var i=n[s],a=i.query,u=i.updater,c=e.cache.diff({query:a.document,variables:a.variables,returnPartialData:!0,optimistic:!1}),l=c.result;if(c.complete){var h=r.tryFunctionOrLogError(function(){return u(l,{mutationResult:t.result,queryName:r.getOperationName(a.document)||void 0,queryVariables:a.variables})});h&&o.push({result:h,dataId:"ROOT_QUERY",query:a.document,variables:a.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}(),_="2.6.0-rc.2",x=!1,I=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,v=t.resolvers,d=t.typeDefs,b=t.fragmentMatcher,m=t.name,g=t.version,Q=t.link;if(!Q&&v&&(Q=o.ApolloLink.empty()),!Q||!r)throw new s.InvariantError(1);this.link=Q,this.cache=r,this.store=new E(r),this.disableNetworkFetches=i||u>0,this.queryDeduplication=h,this.defaultOptions=p||{},this.typeDefs=d,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=_,this.localState=new w({cache:r,client:this,resolvers:v,fragmentMatcher:b}),this.queryManager=new R({link:this.link,store:this.store,queryDeduplication:h,ssrMode:i,clientAwareness:{name:m,version:g},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.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 t.queryManager.clearStore()}).then(function(){return Promise.all(t.clearStoreCallbacks.map(function(t){return t()}))})},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=I,exports.ApolloError=p,exports.ObservableQuery=f,exports.default=I,exports.isApolloError=l; | ||
"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 Array.isArray(t)&&t.length>0}function l(t){return t.hasOwnProperty("graphQLErrors")}var h=function(t){var e="";return c(t.graphQLErrors)&&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$/,"")},p=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||h(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 y=function(t,e){return void 0===e&&(e="none"),t&&(t.networkError||"none"===e&&c(t.graphQLErrors))},f=function(t){function o(e){var o=e.queryManager,n=e.options,s=e.shouldSubscribe,i=void 0===s||s,a=t.call(this,function(t){return a.onSubscribe(t)})||this;a.observers=new Set,a.subscriptions=new Set,a.isTornDown=!1,a.options=n,a.variables=n.variables||{},a.queryId=o.generateQueryId(),a.shouldSubscribe=i;var u=r.getOperationDefinition(n.query);return a.queryName=u&&u.name&&u.name.value,a.queryManager=o,a}return e.__extends(o,t),o.prototype.result=function(){var t=this;return new Promise(function(e,r){var o={next:function(r){e(r),t.observers.delete(o),t.observers.size||t.queryManager.removeQuery(t.queryId),setTimeout(function(){n.unsubscribe()},0)},error:r},n=t.subscribe(o)})},o.prototype.currentResult=function(){var t=this.getCurrentResult();return void 0===t.data&&(t.data={}),t},o.prototype.getCurrentResult=function(){if(this.isTornDown){var t=this.lastResult;return{data:!this.lastError&&t&&t.data||void 0,error:this.lastError,loading:!1,networkStatus:exports.NetworkStatus.error}}var r,o=this.queryManager.getCurrentQueryResult(this),n=o.data,s=o.partial,i=this.queryManager.queryStore.get(this.queryId),u=this.options.fetchPolicy,c="network-only"===u||"no-cache"===u;if(i){var l=i.networkStatus;if(y(i,this.options.errorPolicy))return{data:void 0,loading:!1,networkStatus:l,error:new p({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(l),networkStatus:l},i.graphQLErrors&&"all"===this.options.errorPolicy&&(r.errors=i.graphQLErrors)}else{var h=c||s&&"cache-only"!==u;r={data:n,loading:h,networkStatus:h?exports.NetworkStatus.loading:exports.NetworkStatus.ready}}return s||this.updateLastResult(e.__assign({},r,{stale:!1})),e.__assign({},r,{partial:s})},o.prototype.isDifferentFromLastResult=function(t){var e=this.lastResultSnapshot;return!(e&&t&&e.networkStatus===t.networkStatus&&e.stale===t.stale&&r.isEqual(e.data,t.data))},o.prototype.getLastResult=function(){return this.lastResult},o.prototype.getLastError=function(){return this.lastError},o.prototype.resetLastResults=function(){delete this.lastResult,delete this.lastResultSnapshot,delete this.lastError,this.isTornDown=!1},o.prototype.refetch=function(t){var o=this.options.fetchPolicy;return"cache-only"===o?Promise.reject(new s.InvariantError(3)):("no-cache"!==o&&"cache-and-network"!==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"}),n=this.queryManager.generateQueryId();return this.queryManager.fetchQuery(n,o,exports.FetchType.normal,this.queryId).then(function(e){return r.updateQuery(function(r){return t.updateQuery(r,{fetchMoreResult:e.data,variables:o.variables})}),r.queryManager.stopQuery(n),e},function(t){throw r.queryManager.stopQuery(n),t})},o.prototype.subscribeToMore=function(t){var e=this,r=this.queryManager.startGraphQLSubscription({query:t.document,variables:t.variables}).subscribe({next:function(r){var o=t.updateQuery;o&&e.updateQuery(function(t,e){var n=e.variables;return o(t,{subscriptionData:r,variables:n})})},error:function(e){t.onError&&t.onError(e)}});return this.subscriptions.add(r),function(){e.subscriptions.delete(r)&&r.unsubscribe()}},o.prototype.setOptions=function(t){var r=this.options.fetchPolicy;this.options=e.__assign({},this.options,t),t.pollInterval?this.startPolling(t.pollInterval):0===t.pollInterval&&this.stopPolling();var o=t.fetchPolicy;return this.setVariables(this.options.variables,r!==o&&("cache-only"===r||"standby"===r||"network-only"===o),t.fetchResults)},o.prototype.setVariables=function(t,e,o){return void 0===e&&(e=!1),void 0===o&&(o=!0),this.isTornDown=!1,t=t||this.variables,!e&&r.isEqual(t,this.variables)?this.observers.size&&o?this.result():Promise.resolve():(this.variables=this.options.variables=t,this.observers.size?this.queryManager.fetchQuery(this.queryId,this.options):Promise.resolve())},o.prototype.updateQuery=function(t){var e=this.queryManager,o=e.getQueryWithPreviousResult(this.queryId),n=o.previousResult,s=o.variables,i=o.document,a=r.tryFunctionOrLogError(function(){return t(n,{variables:s})});a&&(e.dataStore.markUpdateQueryResult(i,s,a),e.broadcastQueries())},o.prototype.stopPolling=function(){this.queryManager.stopPollingQuery(this.queryId),this.options.pollInterval=void 0},o.prototype.startPolling=function(t){b(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;try{var r=t._subscription._observer;r&&!r.error&&(r.error=v)}catch(t){}var o=!this.observers.size;return this.observers.add(t),t.next&&this.lastResult&&t.next(this.lastResult),t.error&&this.lastError&&t.error(this.lastError),o&&this.setUpQuery(),function(){e.observers.delete(t)&&!e.observers.size&&e.tearDownQuery()}},o.prototype.setUpQuery=function(){var t=this,e=this.queryManager,o=this.queryId;this.shouldSubscribe&&e.addObservableQuery(o,this),this.options.pollInterval&&(b(this),e.startPollingQuery(this.options,o));var n=function(e){d(t.observers,"error",t.lastError=e)};e.observeQuery(o,this.options,{next:function(o){if(t.lastError||t.isDifferentFromLastResult(o)){var n=t.updateLastResult(o),s=t.options,i=s.query,a=s.variables,u=s.fetchPolicy;e.transform(i).hasClientExports?e.getLocalState().addExportedVariables(i,a).then(function(s){var a=t.variables;t.variables=t.options.variables=s,!o.loading&&n&&"cache-only"!==u&&e.transform(i).serverQuery&&!r.isEqual(a,s)?t.refetch():d(t.observers,"next",o)}):d(t.observers,"next",o)}},error:n}).catch(n)},o.prototype.tearDownQuery=function(){var t=this.queryManager;this.isTornDown=!0,t.stopPollingQuery(this.queryId),this.subscriptions.forEach(function(t){return t.unsubscribe()}),this.subscriptions.clear(),t.removeObservableQuery(this.queryId),t.stopQuery(this.queryId),this.observers.clear()},o}(u);function v(t){}function d(t,e,r){var o=[];t.forEach(function(t){return t[e]&&o.push(t)}),o.forEach(function(t){return t[e](r)})}function b(t){var e=t.options.fetchPolicy;s.invariant("cache-first"!==e&&"cache-only"!==e,5)}var m=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}(),g=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];s.invariant(!e||e.document===t.document||r.isEqual(e.document,t.document),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=c(e.errors)?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){var r=this.store&&this.store[t];r&&(r.networkError=null,r.previousVariables=null,e&&(r.networkStatus=exports.NetworkStatus.ready))},t.prototype.stopQuery=function(t){delete this.store[t]},t.prototype.reset=function(t){var e=this;Object.keys(this.store).forEach(function(r){t.indexOf(r)<0?e.stopQuery(r):e.store[r].networkStatus=exports.NetworkStatus.loading})},t}();function Q(t){return t.charAt(0).toUpperCase()+t.slice(1)}var w=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.buildRootValueFromCache=function(t,e){return this.cache.diff({query:r.buildQueryFromSelectionSet(t),variables:e,returnPartialData:!0,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,v,d;return e.__generator(this,function(b){return u=r.getMainDefinition(t),c=r.getFragmentDefinitions(t),l=r.createFragmentMap(c),h=u.operation,p=h?Q(h):"Query",f=(y=this).cache,v=y.client,d={fragmentMap:l,context:e.__assign({},n,{cache:f,client:v}),variables:s,fragmentMatcher:i,defaultOperationType:p,exportedVariables:{},onlyRunForcedResolvers:a},[2,this.resolveSelectionSet(u.selectionSet,o,d).then(function(t){return{result:t,exportedVariables:d.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.shouldForceResolvers(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 S(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 q(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 k=Object.prototype.hasOwnProperty,R=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 m,this.queryStore=new g,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.link=e,this.queryDeduplication=n,this.dataStore=s,this.onBroadcast=a,this.clientAwareness=h,this.localState=p||new w({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,l=void 0===u?[]:u,h=t.awaitRefetchQueries,y=void 0!==h&&h,f=t.update,v=t.errorPolicy,d=void 0===v?"none":v,b=t.fetchPolicy,m=t.context,g=void 0===m?{}:m;return e.__awaiter(this,void 0,void 0,function(){var t,u,h,v=this;return e.__generator(this,function(m){switch(m.label){case 0:return s.invariant(o,7),s.invariant(!b||"no-cache"===b,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,g)]:[3,2];case 1:n=m.sent(),m.label=2;case 2:return u=function(){var t={};return a&&v.queries.forEach(function(e,r){var o=e.observableQuery;if(o){var n=o.queryName;n&&k.call(a,n)&&(t[r]={updater:a[n],query:v.queryStore.get(r)})}}),t},this.mutationStore.initMutation(t,o,n),this.dataStore.markMutationInit({mutationId:t,document:o,variables:n,updateQueries:u(),update:f,optimisticResponse:i}),this.broadcastQueries(),h=this,[2,new Promise(function(s,a){var v,m;h.getObservableFromLink(o,e.__assign({},g,{optimisticResponse:i}),n,!1).subscribe({next:function(e){r.graphQLResultHasError(e)&&"none"===d?m=new p({graphQLErrors:e.errors}):(h.mutationStore.markMutationResult(t),"no-cache"!==b&&h.dataStore.markMutationResult({mutationId:t,result:e,document:o,variables:n,updateQueries:u(),update:f}),v=e)},error:function(e){h.mutationStore.markMutationError(t,e),h.dataStore.markMutationComplete({mutationId:t,optimisticResponse:i}),h.broadcastQueries(),h.setQuery(t,function(){return{document:null}}),a(new p({networkError:e}))},complete:function(){if(m&&h.mutationStore.markMutationError(t,m),h.dataStore.markMutationComplete({mutationId:t,optimisticResponse:i}),h.broadcastQueries(),m)a(m);else{"function"==typeof l&&(l=l(v));var e=[];c(l)&&l.forEach(function(t){if("string"==typeof t)h.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(h.query(r))}}),Promise.all(y?e:[]).then(function(){h.setQuery(t,function(){return{document:null}}),"ignore"===d&&v&&r.graphQLResultHasError(v)&&delete v.errors,s(v)})}}})})]}})})},t.prototype.fetchQuery=function(t,o,n,s){return e.__awaiter(this,void 0,void 0,function(){var i,a,u,c,h,y,f,v,d,b,m,g,Q,w,S,q,k,R,E=this;return e.__generator(this,function(_){switch(_.label){case 0:return i=o.metadata,a=void 0===i?null:i,u=o.fetchPolicy,c=void 0===u?"cache-first":u,h=o.context,y=void 0===h?{}:h,f=this.transform(o.query).document,v=this.getVariables(f,o.variables),this.transform(f).hasClientExports?[4,this.localState.addExportedVariables(f,v,y)]:[3,2];case 1:v=_.sent(),_.label=2;case 2:if(o=e.__assign({},o,{variables:v}),m=b="network-only"===c||"no-cache"===c,b||(g=this.dataStore.getCache().diff({query:f,variables:v,returnPartialData:!0,optimistic:!1}),Q=g.complete,w=g.result,m=!Q||"cache-and-network"===c,d=w),S=m&&"cache-only"!==c&&"standby"!==c,r.hasDirectives(["live"],f)&&(S=!0),q=this.idCounter++,k="no-cache"!==c?this.updateQueryWatch(t,f,o):void 0,this.setQuery(t,function(){return{document:f,lastRequestId:q,invalidated:!0,cancel:k}}),this.invalidate(s),this.queryStore.initQuery({queryId:t,document:f,storePreviousVariables:S,variables:v,isPoll:n===exports.FetchType.poll,isRefetch:n===exports.FetchType.refetch,metadata:a,fetchMoreForQueryId:s}),this.broadcastQueries(),S){if(R=this.fetchRequest({requestId:q,queryId:t,document:f,options:o,fetchMoreForQueryId:s}).catch(function(e){throw l(e)?e:(q>=E.getQuery(t).lastRequestId&&(E.queryStore.markQueryError(t,e,s),E.invalidate(t),E.invalidate(s),E.broadcastQueries()),new p({networkError:e}))}),"cache-and-network"!==c)return[2,R];R.catch(function(){})}return this.queryStore.markQueryResultClient(t,!S),this.invalidate(t),this.invalidate(s),this.transform(f).hasForcedResolvers?[2,this.localState.runResolvers({document:f,remoteResult:{data:d},context:y,variables:v,onlyRunForcedResolvers:!0}).then(function(e){return E.markQueryResult(t,e,o,s),E.broadcastQueries(),e})]:(this.broadcastQueries(),[2,{data:d}])}})})},t.prototype.markQueryResult=function(t,e,r,o){var n=r.fetchPolicy,s=r.variables,i=r.errorPolicy;"no-cache"===n?this.setQuery(t,function(){return{newData:{result:e.data,complete:!0}}}):this.dataStore.markQueryResult(e,this.getQuery(t).document,s,o,"ignore"===i||"all"===i)},t.prototype.queryListenerForObserver=function(t,e,r){var o=this;function n(t,e){if(r[t])try{r[t](e)}catch(t){}}return function(r,s){if(o.invalidate(t,!1),r){var i=o.getQuery(t),u=i.observableQuery,l=i.document,h=u?u.options.fetchPolicy:e.fetchPolicy;if("standby"!==h){var y=a(r.networkStatus),f=u&&u.getLastResult(),v=!(!f||f.networkStatus===r.networkStatus),d=e.returnPartialData||!s&&r.previousVariables||v&&e.notifyOnNetworkStatusChange||"cache-only"===h||"cache-and-network"===h;if(!y||d){var b=c(r.graphQLErrors),m=u&&u.options.errorPolicy||e.errorPolicy||"none";if("none"===m&&b||r.networkError)return n("error",new p({graphQLErrors:r.graphQLErrors,networkError:r.networkError}));try{var g=void 0,Q=void 0;if(s)"no-cache"!==h&&"network-only"!==h&&o.setQuery(t,function(){return{newData:null}}),g=s.result,Q=!s.complete;else{var w=u&&u.getLastError(),S="none"!==m&&(w&&w.graphQLErrors)!==r.graphQLErrors;if(f&&f.data&&!S)g=f.data,Q=!1;else{var q=o.dataStore.getCache().diff({query:l,variables:r.previousVariables||r.variables,returnPartialData:!0,optimistic:!0});g=q.result,Q=!q.complete}}var k=Q&&!(e.returnPartialData||"cache-only"===h),R={data:k?f&&f.data:g,loading:y,networkStatus:r.networkStatus,stale:k};"all"===m&&b&&(R.errors=r.graphQLErrors),n("next",R)}catch(t){n("error",new p({networkError:t}))}}}}}},t.prototype.transform=function(t){var e=this.transformCache;if(!e.has(t)){var o=this.dataStore.getCache(),n=o.transformDocument(t),s=r.removeConnectionDirectiveFromDocument(o.transformForLink(n)),i=this.localState.clientQuery(n),a=this.localState.serverQuery(s),u={document:n,hasClientExports:r.hasClientExports(n),hasForcedResolvers:this.localState.shouldForceResolvers(n),clientQuery:i,serverQuery:a,defaultVars:r.getDefaultValues(r.getOperationDefinition(n))},c=function(t){t&&!e.has(t)&&e.set(t,u)};c(t),c(n),c(i),c(a)}return e.get(t)},t.prototype.getVariables=function(t,r){return e.__assign({},this.transform(t).defaultVars,r)},t.prototype.watchQuery=function(t,r){void 0===r&&(r=!0),s.invariant("standby"!==t.fetchPolicy,9),t.variables=this.getVariables(t.query,t.variables),void 0===t.notifyOnNetworkStatusChange&&(t.notifyOnNetworkStatusChange=!1);var o=e.__assign({},t);return new f({queryManager:this,options:o,shouldSubscribe:r})},t.prototype.query=function(t){var e=this;return s.invariant(t.query,10),s.invariant("Document"===t.query.kind,11),s.invariant(!t.returnPartialData,12),s.invariant(!t.pollInterval,13),new Promise(function(r,o){var n=e.watchQuery(t,!1);e.fetchQueryRejectFns.set("query:"+n.queryId,o),n.result().then(r,o).then(function(){return e.fetchQueryRejectFns.delete("query:"+n.queryId)})})},t.prototype.generateQueryId=function(){return String(this.idCounter++)},t.prototype.stopQueryInStore=function(t){this.stopQueryInStoreNoBroadcast(t),this.broadcastQueries()},t.prototype.stopQueryInStoreNoBroadcast=function(t){this.stopPollingQuery(t),this.queryStore.stopQuery(t),this.invalidate(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(n)}}),this.broadcastQueries(),Promise.all(r)},t.prototype.observeQuery=function(t,e,r){return this.addQueryListener(t,this.queryListenerForObserver(t,e,r)),this.fetchQuery(t,e)},t.prototype.startQuery=function(t,e,r){return this.addQueryListener(t,r),this.fetchQuery(t,e).catch(function(){}),t},t.prototype.startGraphQLSubscription=function(t){var e=this,o=t.query,n=t.fetchPolicy,s=t.variables;o=this.transform(o).document,s=this.getVariables(o,s);var i=function(t){return e.getObservableFromLink(o,{},t,!1).map(function(s){if(n&&"no-cache"===n||(e.dataStore.markSubscriptionResult(s,o,t),e.broadcastQueries()),r.graphQLResultHasError(s))throw new p({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=r.returnPartialData,a=t.getLastResult(),u=this.getQuery(t.queryId).newData;if(u&&u.complete)return{data:u.result,partial:!1};if("no-cache"===s||"network-only"===s)return{data:void 0,partial:!1};var c=this.dataStore.getCache().diff({query:n,variables:o,previousResult:a?a.data:void 0,returnPartialData:!0,optimistic:e}),l=c.result,h=c.complete;return{data:h||i?l:void 0,partial:!h}},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 v=JSON.stringify(s);if(!(a=f.get(v))){f.set(v,a=S(o.execute(p,y)));var d=function(){f.delete(v),f.size||h.delete(l),b.unsubscribe()},b=a.subscribe({next:d,error:d,complete:d})}}else a=S(o.execute(p,y))}else a=u.of({data:{}}),n=this.prepareContext(n);var m=this.transform(t).clientQuery;return m&&(a=q(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,l=a.variables,h=a.errorPolicy,y=void 0===h?"none":h,f=a.fetchPolicy;return new Promise(function(t,h){var v=o.getObservableFromLink(i,a.context,l),d="fetchRequest:"+s;o.fetchQueryRejectFns.set(d,h);var b=function(){o.fetchQueryRejectFns.delete(d),o.setQuery(s,function(t){t.subscriptions.delete(m)})},m=v.map(function(t){if(n>=o.getQuery(s).lastRequestId&&(o.markQueryResult(s,t,a,u),o.queryStore.markQueryResult(s,t,u),o.invalidate(s),o.invalidate(u),o.broadcastQueries()),"none"===y&&c(t.errors))return h(new p({graphQLErrors:t.errors}));if("all"===y&&(r=t.errors),u||"no-cache"===f)e=t.data;else{var v=o.dataStore.getCache().diff({variables:l,query:i,optimistic:!1,returnPartialData:!0}),d=v.result;(v.complete||a.returnPartialData)&&(e=d)}}).subscribe({error:function(t){b(),h(t)},complete:function(){b(),t({data:e,errors:r,loading:!1,networkStatus:exports.NetworkStatus.ready,stale:!1})}});o.setQuery(s,function(t){t.subscriptions.add(m)})})},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){void 0===e&&(e=!0),t&&this.setQuery(t,function(){return{invalidated:e}})},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=this,i=t.pollInterval;if(s.invariant(i,16),!this.ssrMode){var a=this.pollingInfoByQueryId.get(r);a||this.pollingInfoByQueryId.set(r,a={}),a.interval=i,a.options=e.__assign({},t,{fetchPolicy:"network-only"});var u=function(){var t=n.pollingInfoByQueryId.get(r);t&&(n.checkInFlight(r)?c():n.fetchQuery(r,t.options,exports.FetchType.poll).then(c,c))},c=function(){var t=n.pollingInfoByQueryId.get(r);t&&(clearTimeout(t.timeout),t.timeout=setTimeout(u,t.interval))};o&&this.addQueryListener(r,o),c()}return r},t.prototype.stopPollingQuery=function(t){this.pollingInfoByQueryId.delete(t)},t}(),E=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=[{result:t.result.data,dataId:"ROOT_MUTATION",query:t.document,variables:t.variables}],n=t.updateQueries;n&&Object.keys(n).forEach(function(s){var i=n[s],a=i.query,u=i.updater,c=e.cache.diff({query:a.document,variables:a.variables,returnPartialData:!0,optimistic:!1}),l=c.result;if(c.complete){var h=r.tryFunctionOrLogError(function(){return u(l,{mutationResult:t.result,queryName:r.getOperationName(a.document)||void 0,queryVariables:a.variables})});h&&o.push({result:h,dataId:"ROOT_QUERY",query:a.document,variables:a.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}(),_="2.6.0-rc.3",x=!1,I=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,v=t.resolvers,d=t.typeDefs,b=t.fragmentMatcher,m=t.name,g=t.version,Q=t.link;if(!Q&&v&&(Q=o.ApolloLink.empty()),!Q||!r)throw new s.InvariantError(1);this.link=Q,this.cache=r,this.store=new E(r),this.disableNetworkFetches=i||u>0,this.queryDeduplication=h,this.defaultOptions=p||{},this.typeDefs=d,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=_,this.localState=new w({cache:r,client:this,resolvers:v,fragmentMatcher:b}),this.queryManager=new R({link:this.link,store:this.store,queryDeduplication:h,ssrMode:i,clientAwareness:{name:m,version:g},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.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 t.queryManager.clearStore()}).then(function(){return Promise.all(t.clearStoreCallbacks.map(function(t){return t()}))})},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=I,exports.ApolloError=p,exports.ObservableQuery=f,exports.default=I,exports.isApolloError=l; |
@@ -142,3 +142,4 @@ "use strict"; | ||
} | ||
if (fetchPolicy !== 'no-cache') { | ||
if (fetchPolicy !== 'no-cache' && | ||
fetchPolicy !== 'cache-and-network') { | ||
fetchPolicy = 'network-only'; | ||
@@ -145,0 +146,0 @@ } |
{ | ||
"name": "apollo-client", | ||
"version": "2.6.0-rc.2", | ||
"version": "2.6.0-rc.3", | ||
"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-rc.2"; | ||
export declare const version = "2.6.0-rc.3"; | ||
//# sourceMappingURL=version.d.ts.map |
@@ -1,1 +0,1 @@ | ||
exports.version = "2.6.0-rc.2" | ||
exports.version = "2.6.0-rc.3" |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1154353
9337