apollo-client
Advanced tools
Comparing version 2.5.1 to 2.6.0-beta.0
@@ -24,2 +24,3 @@ import { ApolloLink, FetchResult, GraphQLRequest } from 'apollo-link'; | ||
defaultOptions?: DefaultOptions; | ||
assumeImmutableResults?: boolean; | ||
resolvers?: Resolvers | Resolvers[]; | ||
@@ -35,3 +36,3 @@ typeDefs?: string | string[] | DocumentNode | DocumentNode[]; | ||
cache: ApolloCache<TCacheShape>; | ||
queryManager: QueryManager<TCacheShape> | undefined; | ||
readonly queryManager: QueryManager<TCacheShape>; | ||
disableNetworkFetches: boolean; | ||
@@ -43,7 +44,4 @@ version: string; | ||
private devToolsHookCb; | ||
private proxy; | ||
private ssrMode; | ||
private resetStoreCallbacks; | ||
private clearStoreCallbacks; | ||
private clientAwareness; | ||
private localState; | ||
@@ -55,3 +53,3 @@ constructor(options: ApolloClientOptions<TCacheShape>); | ||
mutate<T = any, TVariables = OperationVariables>(options: MutationOptions<T, TVariables>): Promise<FetchResult<T>>; | ||
subscribe<T = any, TVariables = OperationVariables>(options: SubscriptionOptions<TVariables>): Observable<T>; | ||
subscribe<T = any, TVariables = OperationVariables>(options: SubscriptionOptions<TVariables>): Observable<FetchResult<T>>; | ||
readQuery<T = any, TVariables = OperationVariables>(options: DataProxy.Query<TVariables>, optimistic?: boolean): T | null; | ||
@@ -69,3 +67,3 @@ readFragment<T = any, TVariables = OperationVariables>(options: DataProxy.Fragment<TVariables>, optimistic?: boolean): T | null; | ||
onClearStore(cb: () => Promise<any>): () => void; | ||
reFetchObservableQueries(includeStandby?: boolean): Promise<ApolloQueryResult<any>[]> | Promise<null>; | ||
reFetchObservableQueries(includeStandby?: boolean): Promise<ApolloQueryResult<any>[]>; | ||
extract(optimistic?: boolean): TCacheShape; | ||
@@ -77,4 +75,3 @@ restore(serializedState: TCacheShape): ApolloCache<TCacheShape>; | ||
setLocalStateFragmentMatcher(fragmentMatcher: FragmentMatcher): void; | ||
private initProxy; | ||
} | ||
//# sourceMappingURL=ApolloClient.d.ts.map |
@@ -18,4 +18,3 @@ "use strict"; | ||
this.clearStoreCallbacks = []; | ||
this.clientAwareness = {}; | ||
var cache = options.cache, _a = options.ssrMode, ssrMode = _a === void 0 ? false : _a, _b = options.ssrForceFetchDelay, ssrForceFetchDelay = _b === void 0 ? 0 : _b, connectToDevTools = options.connectToDevTools, _c = options.queryDeduplication, queryDeduplication = _c === void 0 ? true : _c, defaultOptions = options.defaultOptions, resolvers = options.resolvers, typeDefs = options.typeDefs, fragmentMatcher = options.fragmentMatcher, clientAwarenessName = options.name, clientAwarenessVersion = options.version; | ||
var cache = options.cache, _a = options.ssrMode, ssrMode = _a === void 0 ? false : _a, _b = options.ssrForceFetchDelay, ssrForceFetchDelay = _b === void 0 ? 0 : _b, connectToDevTools = options.connectToDevTools, _c = options.queryDeduplication, queryDeduplication = _c === void 0 ? true : _c, defaultOptions = options.defaultOptions, _d = options.assumeImmutableResults, assumeImmutableResults = _d === void 0 ? false : _d, resolvers = options.resolvers, typeDefs = options.typeDefs, fragmentMatcher = options.fragmentMatcher, clientAwarenessName = options.name, clientAwarenessVersion = options.version; | ||
var link = options.link; | ||
@@ -26,3 +25,5 @@ if (!link && resolvers) { | ||
if (!link || !cache) { | ||
throw new ts_invariant_1.InvariantError("\n In order to initialize Apollo Client, you must specify link & cache properties on the config object.\n This is part of the required upgrade when migrating from Apollo Client 1.0 to Apollo Client 2.0.\n For more information, please visit:\n https://www.apollographql.com/docs/react/basics/setup.html\n to help you get started.\n "); | ||
throw new ts_invariant_1.InvariantError("In order to initialize Apollo Client, you must specify 'link' and 'cache' properties in the options object.\n" + | ||
"These options are part of the upgrade requirements when migrating from Apollo Client 1.x to Apollo Client 2.x.\n" + | ||
"For more information, please visit: https://www.apollographql.com/docs/tutorial/client.html#apollo-client-setup"); | ||
} | ||
@@ -45,3 +46,2 @@ var supportedCache = new Map(); | ||
this.queryDeduplication = queryDeduplication; | ||
this.ssrMode = ssrMode; | ||
this.defaultOptions = defaultOptions || {}; | ||
@@ -82,8 +82,2 @@ this.typeDefs = typeDefs; | ||
this.version = version_1.version; | ||
if (clientAwarenessName) { | ||
this.clientAwareness.name = clientAwarenessName; | ||
} | ||
if (clientAwarenessVersion) { | ||
this.clientAwareness.version = clientAwarenessVersion; | ||
} | ||
this.localState = new LocalState_1.LocalState({ | ||
@@ -95,2 +89,26 @@ cache: cache, | ||
}); | ||
this.queryManager = new QueryManager_1.QueryManager({ | ||
link: this.link, | ||
store: this.store, | ||
queryDeduplication: queryDeduplication, | ||
ssrMode: ssrMode, | ||
clientAwareness: { | ||
name: clientAwarenessName, | ||
version: clientAwarenessVersion, | ||
}, | ||
localState: this.localState, | ||
assumeImmutableResults: assumeImmutableResults, | ||
onBroadcast: function () { | ||
if (_this.devToolsHookCb) { | ||
_this.devToolsHookCb({ | ||
action: {}, | ||
state: { | ||
queries: _this.queryManager.queryStore.getStore(), | ||
mutations: _this.queryManager.mutationStore.getStore(), | ||
}, | ||
dataWithOptimisticResults: _this.cache.extract(true), | ||
}); | ||
} | ||
}, | ||
}); | ||
} | ||
@@ -111,3 +129,3 @@ ApolloClient.prototype.stop = function () { | ||
} | ||
return this.initQueryManager().watchQuery(options); | ||
return this.queryManager.watchQuery(options); | ||
}; | ||
@@ -122,3 +140,3 @@ ApolloClient.prototype.query = function (options) { | ||
} | ||
return this.initQueryManager().query(options); | ||
return this.queryManager.query(options); | ||
}; | ||
@@ -129,28 +147,28 @@ ApolloClient.prototype.mutate = function (options) { | ||
} | ||
return this.initQueryManager().mutate(options); | ||
return this.queryManager.mutate(options); | ||
}; | ||
ApolloClient.prototype.subscribe = function (options) { | ||
return this.initQueryManager().startGraphQLSubscription(options); | ||
return this.queryManager.startGraphQLSubscription(options); | ||
}; | ||
ApolloClient.prototype.readQuery = function (options, optimistic) { | ||
if (optimistic === void 0) { optimistic = false; } | ||
return this.initProxy().readQuery(options, optimistic); | ||
return this.cache.readQuery(options, optimistic); | ||
}; | ||
ApolloClient.prototype.readFragment = function (options, optimistic) { | ||
if (optimistic === void 0) { optimistic = false; } | ||
return this.initProxy().readFragment(options, optimistic); | ||
return this.cache.readFragment(options, optimistic); | ||
}; | ||
ApolloClient.prototype.writeQuery = function (options) { | ||
var result = this.initProxy().writeQuery(options); | ||
this.initQueryManager().broadcastQueries(); | ||
var result = this.cache.writeQuery(options); | ||
this.queryManager.broadcastQueries(); | ||
return result; | ||
}; | ||
ApolloClient.prototype.writeFragment = function (options) { | ||
var result = this.initProxy().writeFragment(options); | ||
this.initQueryManager().broadcastQueries(); | ||
var result = this.cache.writeFragment(options); | ||
this.queryManager.broadcastQueries(); | ||
return result; | ||
}; | ||
ApolloClient.prototype.writeData = function (options) { | ||
var result = this.initProxy().writeData(options); | ||
this.initQueryManager().broadcastQueries(); | ||
var result = this.cache.writeData(options); | ||
this.queryManager.broadcastQueries(); | ||
return result; | ||
@@ -165,29 +183,4 @@ }; | ||
ApolloClient.prototype.initQueryManager = function () { | ||
var _this = this; | ||
if (!this.queryManager) { | ||
this.queryManager = new QueryManager_1.QueryManager({ | ||
link: this.link, | ||
store: this.store, | ||
queryDeduplication: this.queryDeduplication, | ||
ssrMode: this.ssrMode, | ||
clientAwareness: this.clientAwareness, | ||
localState: this.localState, | ||
onBroadcast: function () { | ||
if (_this.devToolsHookCb) { | ||
_this.devToolsHookCb({ | ||
action: {}, | ||
state: { | ||
queries: _this.queryManager | ||
? _this.queryManager.queryStore.getStore() | ||
: {}, | ||
mutations: _this.queryManager | ||
? _this.queryManager.mutationStore.getStore() | ||
: {}, | ||
}, | ||
dataWithOptimisticResults: _this.cache.extract(true), | ||
}); | ||
} | ||
}, | ||
}); | ||
} | ||
ts_invariant_1.invariant.warn('Calling the initQueryManager method is no longer necessary, ' + | ||
'and it will be removed from ApolloClient in version 3.0.'); | ||
return this.queryManager; | ||
@@ -198,22 +191,11 @@ }; | ||
return Promise.resolve() | ||
.then(function () { | ||
return _this.queryManager | ||
? _this.queryManager.clearStore() | ||
: Promise.resolve(null); | ||
}) | ||
.then(function () { return _this.queryManager.clearStore(); }) | ||
.then(function () { return Promise.all(_this.resetStoreCallbacks.map(function (fn) { return fn(); })); }) | ||
.then(function () { | ||
return _this.queryManager && _this.queryManager.reFetchObservableQueries | ||
? _this.queryManager.reFetchObservableQueries() | ||
: Promise.resolve(null); | ||
}); | ||
.then(function () { return _this.reFetchObservableQueries(); }); | ||
}; | ||
ApolloClient.prototype.clearStore = function () { | ||
var _this = this; | ||
var queryManager = this.queryManager; | ||
return Promise.resolve() | ||
.then(function () { return Promise.all(_this.clearStoreCallbacks.map(function (fn) { return fn(); })); }) | ||
.then(function () { | ||
return queryManager ? queryManager.clearStore() : Promise.resolve(null); | ||
}); | ||
.then(function () { return _this.queryManager.clearStore(); }); | ||
}; | ||
@@ -235,11 +217,9 @@ ApolloClient.prototype.onResetStore = function (cb) { | ||
ApolloClient.prototype.reFetchObservableQueries = function (includeStandby) { | ||
return this.queryManager | ||
? this.queryManager.reFetchObservableQueries(includeStandby) | ||
: Promise.resolve(null); | ||
return this.queryManager.reFetchObservableQueries(includeStandby); | ||
}; | ||
ApolloClient.prototype.extract = function (optimistic) { | ||
return this.initProxy().extract(optimistic); | ||
return this.cache.extract(optimistic); | ||
}; | ||
ApolloClient.prototype.restore = function (serializedState) { | ||
return this.initProxy().restore(serializedState); | ||
return this.cache.restore(serializedState); | ||
}; | ||
@@ -258,9 +238,2 @@ ApolloClient.prototype.addResolvers = function (resolvers) { | ||
}; | ||
ApolloClient.prototype.initProxy = function () { | ||
if (!this.proxy) { | ||
this.initQueryManager(); | ||
this.proxy = this.cache; | ||
} | ||
return this.proxy; | ||
}; | ||
return ApolloClient; | ||
@@ -267,0 +240,0 @@ }()); |
@@ -1,1 +0,1 @@ | ||
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("tslib"),r=require("apollo-utilities"),o=require("apollo-link"),n=e(require("symbol-observable")),i=require("ts-invariant"),s=require("apollo-link-dedup"),a=require("graphql/language/visitor");function u(e){return e<7}!function(e){e[e.loading=1]="loading",e[e.setVariables=2]="setVariables",e[e.fetchMore=3]="fetchMore",e[e.refetch=4]="refetch",e[e.poll=6]="poll",e[e.ready=7]="ready",e[e.error=8]="error"}(exports.NetworkStatus||(exports.NetworkStatus={}));var c=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t.__extends(r,e),r.prototype[n]=function(){return this},r.prototype["@@observable"]=function(){return this},r}(o.Observable);function l(e){return e.hasOwnProperty("graphQLErrors")}var h=function(e){var t="";return Array.isArray(e.graphQLErrors)&&0!==e.graphQLErrors.length&&e.graphQLErrors.forEach(function(e){var r=e?e.message:"Error message not found.";t+="GraphQL error: "+r+"\n"}),e.networkError&&(t+="Network error: "+e.networkError.message+"\n"),t=t.replace(/\n$/,"")},p=function(e){function r(t){var o=t.graphQLErrors,n=t.networkError,i=t.errorMessage,s=t.extraInfo,a=e.call(this,i)||this;return a.graphQLErrors=o||[],a.networkError=n||null,a.message=i||h(a),a.extraInfo=s,a.__proto__=r.prototype,a}return t.__extends(r,e),r}(Error);!function(e){e[e.normal=1]="normal",e[e.refetch=2]="refetch",e[e.poll=3]="poll"}(exports.FetchType||(exports.FetchType={}));var y=function(e,t){return void 0===t&&(t="none"),e&&(e.graphQLErrors&&e.graphQLErrors.length>0&&"none"===t||e.networkError)},f=function(e){function o(t){var r=t.queryManager,o=t.options,n=t.shouldSubscribe,i=void 0===n||n,s=e.call(this,function(e){return s.onSubscribe(e)})||this;return s.isTornDown=!1,s.options=o,s.variables=o.variables||{},s.queryId=r.generateQueryId(),s.shouldSubscribe=i,s.queryManager=r,s.observers=[],s.subscriptionHandles=[],s}return t.__extends(o,e),o.prototype.result=function(){var e=this;return new Promise(function(t,r){var o,n={next:function(r){t(r),e.observers.some(function(e){return e!==n})||e.queryManager.removeQuery(e.queryId),setTimeout(function(){o.unsubscribe()},0)},error:function(e){r(e)}};o=e.subscribe(n)})},o.prototype.currentResult=function(){var e=this.getCurrentResult();return void 0===e.data&&(e.data={}),e},o.prototype.getCurrentResult=function(){if(this.isTornDown)return{data:this.lastError?void 0:this.lastResult?this.lastResult.data:void 0,error:this.lastError,loading:!1,networkStatus:exports.NetworkStatus.error};var e=this.queryManager.queryStore.get(this.queryId);if(y(e,this.options.errorPolicy))return{data:void 0,loading:!1,networkStatus:e.networkStatus,error:new p({graphQLErrors:e.graphQLErrors,networkError:e.networkError})};e&&e.variables&&(this.options.variables=Object.assign({},this.options.variables,e.variables));var o,n=this.queryManager.getCurrentQueryResult(this),i=n.data,s=n.partial,a=!e||e.networkStatus===exports.NetworkStatus.loading,c="network-only"===this.options.fetchPolicy&&a||s&&"cache-only"!==this.options.fetchPolicy,l={data:i,loading:u(o=e?e.networkStatus:c?exports.NetworkStatus.loading:exports.NetworkStatus.ready),networkStatus:o};return e&&e.graphQLErrors&&"all"===this.options.errorPolicy&&(l.errors=e.graphQLErrors),s||(this.lastResult=t.__assign({},l,{stale:!1}),this.lastResultSnapshot=r.cloneDeep(this.lastResult)),t.__assign({},l,{partial:s})},o.prototype.isDifferentFromLastResult=function(e){var t=this.lastResultSnapshot;return!(t&&e&&t.networkStatus===e.networkStatus&&t.stale===e.stale&&r.isEqual(t.data,e.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(e){var o=this.options.fetchPolicy;if("cache-only"===o)return Promise.reject(new Error("cache-only fetchPolicy option should not be used together with query refetch."));r.isEqual(this.variables,e)||(this.variables=Object.assign({},this.variables,e)),r.isEqual(this.options.variables,this.variables)||(this.options.variables=Object.assign({},this.options.variables,this.variables));var n="network-only"===o||"no-cache"===o,i=t.__assign({},this.options,{fetchPolicy:n?o:"network-only"});return this.queryManager.fetchQuery(this.queryId,i,exports.FetchType.refetch).then(function(e){return e})},o.prototype.fetchMore=function(e){var r,o=this;return i.invariant(e.updateQuery),Promise.resolve().then(function(){var n=o.queryManager.generateQueryId();return(r=e.query?e:t.__assign({},o.options,e,{variables:Object.assign({},o.variables,e.variables)})).fetchPolicy="network-only",o.queryManager.fetchQuery(n,r,exports.FetchType.normal,o.queryId)}).then(function(t){return o.updateQuery(function(o){return e.updateQuery(o,{fetchMoreResult:t.data,variables:r.variables})}),t})},o.prototype.subscribeToMore=function(e){var t=this,r=this.queryManager.startGraphQLSubscription({query:e.document,variables:e.variables}).subscribe({next:function(r){e.updateQuery&&t.updateQuery(function(t,o){var n=o.variables;return e.updateQuery(t,{subscriptionData:r,variables:n})})},error:function(t){e.onError?e.onError(t):console.error("Unhandled GraphQL subscription error",t)}});return this.subscriptionHandles.push(r),function(){var e=t.subscriptionHandles.indexOf(r);e>=0&&(t.subscriptionHandles.splice(e,1),r.unsubscribe())}},o.prototype.setOptions=function(e){var t=this.options;this.options=Object.assign({},this.options,e),e.pollInterval?this.startPolling(e.pollInterval):0===e.pollInterval&&this.stopPolling();var r="network-only"!==t.fetchPolicy&&"network-only"===e.fetchPolicy||"cache-only"===t.fetchPolicy&&"cache-only"!==e.fetchPolicy||"standby"===t.fetchPolicy&&"standby"!==e.fetchPolicy||!1;return this.setVariables(this.options.variables,r,e.fetchResults)},o.prototype.setVariables=function(e,o,n){void 0===o&&(o=!1),void 0===n&&(n=!0),this.isTornDown=!1;var i=e||this.variables;return r.isEqual(i,this.variables)&&!o?0!==this.observers.length&&n?this.result():new Promise(function(e){return e()}):(this.variables=i,this.options.variables=i,0===this.observers.length?new Promise(function(e){return e()}):this.queryManager.fetchQuery(this.queryId,t.__assign({},this.options,{variables:this.variables})).then(function(e){return e}))},o.prototype.updateQuery=function(e){var t=this.queryManager.getQueryWithPreviousResult(this.queryId),o=t.previousResult,n=t.variables,i=t.document,s=r.tryFunctionOrLogError(function(){return e(o,{variables:n})});s&&(this.queryManager.dataStore.markUpdateQueryResult(i,n,s),this.queryManager.broadcastQueries())},o.prototype.stopPolling=function(){this.queryManager.stopPollingQuery(this.queryId),this.options.pollInterval=void 0},o.prototype.startPolling=function(e){d(this),this.options.pollInterval=e,this.queryManager.startPollingQuery(this.options,this.queryId)},o.prototype.onSubscribe=function(e){var t=this;return e._subscription&&e._subscription._observer&&!e._subscription._observer.error&&(e._subscription._observer.error=function(e){console.error("Unhandled error",e.message,e.stack)}),this.observers.push(e),e.next&&this.lastResult&&e.next(this.lastResult),e.error&&this.lastError&&e.error(this.lastError),1===this.observers.length&&this.setUpQuery(),function(){t.observers=t.observers.filter(function(t){return t!==e}),0===t.observers.length&&t.tearDownQuery()}},o.prototype.setUpQuery=function(){var e=this;this.shouldSubscribe&&this.queryManager.addObservableQuery(this.queryId,this),this.options.pollInterval&&(d(this),this.queryManager.startPollingQuery(this.options,this.queryId));var t={next:function(t){e.lastResult=t,e.lastResultSnapshot=r.cloneDeep(t),e.observers.forEach(function(e){return e.next&&e.next(t)})},error:function(t){e.lastError=t,e.observers.forEach(function(e){return e.error&&e.error(t)})}};this.queryManager.startQuery(this.queryId,this.options,this.queryManager.queryListenerForObserver(this.queryId,this.options,t))},o.prototype.tearDownQuery=function(){this.isTornDown=!0,this.queryManager.stopPollingQuery(this.queryId),this.subscriptionHandles.forEach(function(e){return e.unsubscribe()}),this.subscriptionHandles=[],this.queryManager.removeObservableQuery(this.queryId),this.queryManager.stopQuery(this.queryId),this.observers=[]},o}(c);function d(e){var t=e.options.fetchPolicy;i.invariant("cache-first"!==t&&"cache-only"!==t)}var v=function(){function e(){this.store={}}return e.prototype.getStore=function(){return this.store},e.prototype.get=function(e){return this.store[e]},e.prototype.initMutation=function(e,t,r){this.store[e]={mutation:t,variables:r||{},loading:!0,error:null}},e.prototype.markMutationError=function(e,t){var r=this.store[e];r&&(r.loading=!1,r.error=t)},e.prototype.markMutationResult=function(e){var t=this.store[e];t&&(t.loading=!1,t.error=null)},e.prototype.reset=function(){this.store={}},e}(),b=function(){function e(){this.store={}}return e.prototype.getStore=function(){return this.store},e.prototype.get=function(e){return this.store[e]},e.prototype.initQuery=function(e){var t=this.store[e.queryId];if(t&&t.document!==e.document&&!r.isEqual(t.document,e.document))throw new i.InvariantError;var o,n=!1,s=null;e.storePreviousVariables&&t&&t.networkStatus!==exports.NetworkStatus.loading&&(r.isEqual(t.variables,e.variables)||(n=!0,s=t.variables)),o=n?exports.NetworkStatus.setVariables:e.isPoll?exports.NetworkStatus.poll:e.isRefetch?exports.NetworkStatus.refetch:exports.NetworkStatus.loading;var a=[];t&&t.graphQLErrors&&(a=t.graphQLErrors),this.store[e.queryId]={document:e.document,variables:e.variables,previousVariables:s,networkError:null,graphQLErrors:a,networkStatus:o,metadata:e.metadata},"string"==typeof e.fetchMoreForQueryId&&this.store[e.fetchMoreForQueryId]&&(this.store[e.fetchMoreForQueryId].networkStatus=exports.NetworkStatus.fetchMore)},e.prototype.markQueryResult=function(e,t,r){this.store&&this.store[e]&&(this.store[e].networkError=null,this.store[e].graphQLErrors=t.errors&&t.errors.length?t.errors:[],this.store[e].previousVariables=null,this.store[e].networkStatus=exports.NetworkStatus.ready,"string"==typeof r&&this.store[r]&&(this.store[r].networkStatus=exports.NetworkStatus.ready))},e.prototype.markQueryError=function(e,t,r){this.store&&this.store[e]&&(this.store[e].networkError=t,this.store[e].networkStatus=exports.NetworkStatus.error,"string"==typeof r&&this.markQueryResultClient(r,!0))},e.prototype.markQueryResultClient=function(e,t){this.store&&this.store[e]&&(this.store[e].networkError=null,this.store[e].previousVariables=null,this.store[e].networkStatus=t?exports.NetworkStatus.ready:exports.NetworkStatus.loading)},e.prototype.stopQuery=function(e){delete this.store[e]},e.prototype.reset=function(e){var r=this;this.store=Object.keys(this.store).filter(function(t){return e.indexOf(t)>-1}).reduce(function(e,o){return e[o]=t.__assign({},r.store[o],{networkStatus:exports.NetworkStatus.loading}),e},{})},e}();function g(e){return e.charAt(0).toUpperCase()+e.slice(1)}var m=function(){function e(e){var t=e.cache,r=e.client,o=e.resolvers,n=e.fragmentMatcher;this.cache=t,r&&(this.client=r),o&&this.addResolvers(o),n&&this.setFragmentMatcher(n)}return e.prototype.addResolvers=function(e){var t=this;this.resolvers=this.resolvers||{},Array.isArray(e)?e.forEach(function(e){t.resolvers=r.mergeDeep(t.resolvers,e)}):this.resolvers=r.mergeDeep(this.resolvers,e)},e.prototype.setResolvers=function(e){this.resolvers={},this.addResolvers(e)},e.prototype.getResolvers=function(){return this.resolvers||{}},e.prototype.runResolvers=function(e){var r=e.document,o=e.remoteResult,n=e.context,i=e.variables,s=e.onlyRunForcedResolvers,a=void 0!==s&&s;return t.__awaiter(this,void 0,void 0,function(){return t.__generator(this,function(e){return r?[2,this.resolveDocument(r,o.data,n,i,this.fragmentMatcher,a).then(function(e){return t.__assign({},o,{data:e.result})})]:[2,o]})})},e.prototype.setFragmentMatcher=function(e){this.fragmentMatcher=e},e.prototype.getFragmentMatcher=function(){return this.fragmentMatcher},e.prototype.clientQuery=function(e){return r.hasDirectives(["client"],e)&&this.resolvers?e:null},e.prototype.serverQuery=function(e){return this.resolvers?r.removeClientSetsFromDocument(e):e},e.prototype.prepareContext=function(e){void 0===e&&(e={});var r=this.cache;return t.__assign({},e,{cache:r,getCacheKey:function(e){if(r.config)return r.config.dataIdFromObject(e);i.invariant(!1)}})},e.prototype.addExportedVariables=function(e,r,o){return void 0===r&&(r={}),void 0===o&&(o={}),t.__awaiter(this,void 0,void 0,function(){return t.__generator(this,function(n){return e?[2,this.resolveDocument(e,this.buildRootValueFromCache(e,r)||{},this.prepareContext(o),r).then(function(e){return t.__assign({},r,e.exportedVariables)})]:[2,t.__assign({},r)]})})},e.prototype.shouldForceResolvers=function(e){var t=!1;return a.visit(e,{Directive:{enter:function(e){if("client"===e.name.value&&e.arguments&&(t=e.arguments.some(function(e){return"always"===e.name.value&&"BooleanValue"===e.value.kind&&!0===e.value.value})))return a.BREAK}}}),t},e.prototype.shouldForceResolver=function(e){return this.shouldForceResolvers(e)},e.prototype.buildRootValueFromCache=function(e,t){return this.cache.diff({query:r.buildQueryFromSelectionSet(e),variables:t,optimistic:!1}).result},e.prototype.resolveDocument=function(e,o,n,i,s,a){return void 0===n&&(n={}),void 0===i&&(i={}),void 0===s&&(s=function(){return!0}),void 0===a&&(a=!1),t.__awaiter(this,void 0,void 0,function(){var u,c,l,h,p,y,f,d,v;return t.__generator(this,function(b){return u=r.getMainDefinition(e),c=r.getFragmentDefinitions(e),l=r.createFragmentMap(c),h=u.operation,p=h?g(h):"Query",f=(y=this).cache,d=y.client,v={fragmentMap:l,context:t.__assign({},n,{cache:f,client:d}),variables:i,fragmentMatcher:s,defaultOperationType:p,exportedVariables:{},onlyRunForcedResolvers:a},[2,this.resolveSelectionSet(u.selectionSet,o,v).then(function(e){return{result:e,exportedVariables:v.exportedVariables}})]})})},e.prototype.resolveSelectionSet=function(e,o,n){return t.__awaiter(this,void 0,void 0,function(){var s,a,u,c,l,h=this;return t.__generator(this,function(p){return s=n.fragmentMap,a=n.context,u=n.variables,c=[o],l=function(e){return t.__awaiter(h,void 0,void 0,function(){var l,h;return t.__generator(this,function(t){return r.shouldInclude(e,u)?r.isField(e)?[2,this.resolveField(e,o,n).then(function(t){var o;void 0!==t&&c.push(((o={})[r.resultKeyNameFromField(e)]=t,o))})]:(r.isInlineFragment(e)?l=e:(l=s[e.name.value],i.invariant(l)),l&&l.typeCondition&&(h=l.typeCondition.name.value,n.fragmentMatcher(o,h,a))?[2,this.resolveSelectionSet(l.selectionSet,o,n).then(function(e){c.push(e)})]:[2]):[2]})})},[2,Promise.all(e.selections.map(l)).then(function(){return r.mergeDeepArray(c)})]})})},e.prototype.resolveField=function(e,o,n){return t.__awaiter(this,void 0,void 0,function(){var i,s,a,u,c,l,h,p,y,f=this;return t.__generator(this,function(t){return i=n.variables,s=e.name.value,a=r.resultKeyNameFromField(e),u=s!==a,c=o[a]||o[s],l=Promise.resolve(c),n.onlyRunForcedResolvers&&!this.shouldForceResolver(e)||(h=o.__typename||n.defaultOperationType,(p=this.resolvers&&this.resolvers[h])&&(y=p[u?s:a])&&(l=Promise.resolve(y(o,r.argumentsObjectFromField(e,i),n.context,{field:e})))),[2,l.then(function(t){return void 0===t&&(t=c),e.directives&&e.directives.forEach(function(e){"export"===e.name.value&&e.arguments&&e.arguments.forEach(function(e){"as"===e.name.value&&"StringValue"===e.value.kind&&(n.exportedVariables[e.value.value]=t)})}),e.selectionSet?null==t?t:Array.isArray(t)?f.resolveSubSelectedArray(e,t,n):e.selectionSet?f.resolveSelectionSet(e.selectionSet,t,n):void 0:t})]})})},e.prototype.resolveSubSelectedArray=function(e,t,r){var o=this;return Promise.all(t.map(function(t){return null===t?null:Array.isArray(t)?o.resolveSubSelectedArray(e,t,r):e.selectionSet?o.resolveSelectionSet(e.selectionSet,t,r):void 0}))},e}(),Q=function(){function e(e){var t=e.link,r=e.queryDeduplication,n=void 0!==r&&r,i=e.store,a=e.onBroadcast,u=void 0===a?function(){}:a,c=e.ssrMode,l=void 0!==c&&c,h=e.clientAwareness,p=void 0===h?{}:h,y=e.localState;this.mutationStore=new v,this.queryStore=new b,this.clientAwareness={},this.idCounter=1,this.queries=new Map,this.fetchQueryRejectFns=new Map,this.queryIdsByName={},this.pollingInfoByQueryId=new Map,this.nextPoll=null,this.link=t,this.deduplicator=o.ApolloLink.from([new s.DedupLink,t]),this.queryDeduplication=n,this.dataStore=i,this.onBroadcast=u,this.clientAwareness=p,this.localState=y||new m({cache:i.getCache()}),this.ssrMode=l}return e.prototype.stop=function(){var e=this;this.queries.forEach(function(t,r){e.stopQueryNoBroadcast(r)}),this.fetchQueryRejectFns.forEach(function(e){e(new Error("QueryManager stopped while query was in flight"))})},e.prototype.mutate=function(e){var n=e.mutation,s=e.variables,a=e.optimisticResponse,u=e.updateQueries,l=e.refetchQueries,h=void 0===l?[]:l,y=e.awaitRefetchQueries,f=void 0!==y&&y,d=e.update,v=e.errorPolicy,b=void 0===v?"none":v,g=e.fetchPolicy,m=e.context,Q=void 0===m?{}:m;return t.__awaiter(this,void 0,void 0,function(){var e,l,y,v,m,w=this;return t.__generator(this,function(S){switch(S.label){case 0:return i.invariant(n),i.invariant(!g||"no-cache"===g),e=this.generateQueryId(),l=this.dataStore.getCache(),n=l.transformDocument(n),s=r.assign({},r.getDefaultValues(r.getMutationDefinition(n)),s),this.setQuery(e,function(){return{document:n}}),y=function(){var e={};return u&&Object.keys(u).forEach(function(t){return(w.queryIdsByName[t]||[]).forEach(function(r){e[r]={updater:u[t],query:w.queryStore.get(r)}})}),e},r.hasClientExports(n)?[4,this.localState.addExportedVariables(n,s,Q)]:[3,2];case 1:return m=S.sent(),[3,3];case 2:m=s,S.label=3;case 3:return v=m,this.mutationStore.initMutation(e,n,v),this.dataStore.markMutationInit({mutationId:e,document:n,variables:v||{},updateQueries:y(),update:d,optimisticResponse:a}),this.broadcastQueries(),[2,new Promise(function(i,s){var u,l,m=w.buildOperationForLink(n,v,t.__assign({},Q,{optimisticResponse:a})),S=function(){if(l&&w.mutationStore.markMutationError(e,l),w.dataStore.markMutationComplete({mutationId:e,optimisticResponse:a}),w.broadcastQueries(),l)return Promise.reject(l);"function"==typeof h&&(h=h(u));for(var t=[],o=0,n=h;o<n.length;o++){var i=n[o];if("string"!=typeof i){var s={query:i.query,variables:i.variables,fetchPolicy:"network-only"};i.context&&(s.context=i.context),t.push(w.query(s))}else{var c=w.refetchQueryByName(i);c&&t.push(c)}}return Promise.all(f?t:[]).then(function(){return w.setQuery(e,function(){return{document:null}}),"ignore"===b&&u&&r.graphQLResultHasError(u)&&delete u.errors,u})},q=w.localState.clientQuery(m.query),k=w.localState.serverQuery(m.query);k&&(m.query=k);var R=k?o.execute(w.link,m):c.of({data:{}}),_=w,E=!1,x=!1;R.subscribe({next:function(o){return t.__awaiter(w,void 0,void 0,function(){var a,c,h;return t.__generator(this,function(t){switch(t.label){case 0:return x=!0,r.graphQLResultHasError(o)&&"none"===b?(x=!1,l=new p({graphQLErrors:o.errors}),[2]):(_.mutationStore.markMutationResult(e),a=o,c=m.context,h=m.variables,q&&r.hasDirectives(["client"],q)?[4,_.localState.runResolvers({document:q,remoteResult:o,context:c,variables:h}).catch(function(e){return x=!1,s(e),o})]:[3,2]);case 1:a=t.sent(),t.label=2;case 2:return"no-cache"!==g&&_.dataStore.markMutationResult({mutationId:e,result:a,document:n,variables:v||{},updateQueries:y(),update:d}),u=a,x=!1,E&&S().then(i,s),[2]}})})},error:function(t){_.mutationStore.markMutationError(e,t),_.dataStore.markMutationComplete({mutationId:e,optimisticResponse:a}),_.broadcastQueries(),_.setQuery(e,function(){return{document:null}}),s(new p({networkError:t}))},complete:function(){x||S().then(i,s),E=!0}})})]}})})},e.prototype.fetchQuery=function(e,o,n,i){return t.__awaiter(this,void 0,void 0,function(){var s,a,u,c,h,y,f,d,v,b,g,m,Q,w,S,q,k,R,_,E,x,M,P=this;return t.__generator(this,function(I){switch(I.label){case 0:return s=o.variables,a=void 0===s?{}:s,u=o.metadata,c=void 0===u?null:u,h=o.fetchPolicy,y=void 0===h?"cache-first":h,f=o.context,d=void 0===f?{}:f,v=this.dataStore.getCache(),b=v.transformDocument(o.query),r.hasClientExports(b)?[4,this.localState.addExportedVariables(b,a,d)]:[3,2];case 1:return m=I.sent(),[3,3];case 2:m=a,I.label=3;case 3:if(g=m,Q=t.__assign({},o,{variables:g}),S="network-only"===y||"no-cache"===y,n!==exports.FetchType.refetch&&"network-only"!==y&&"no-cache"!==y&&(q=this.dataStore.getCache().diff({query:b,variables:g,returnPartialData:!0,optimistic:!1}),k=q.complete,R=q.result,S=!k||"cache-and-network"===y,w=R),_=S&&"cache-only"!==y&&"standby"!==y,r.hasDirectives(["live"],b)&&(_=!0),E=this.generateRequestId(),x=this.updateQueryWatch(e,b,Q),this.setQuery(e,function(){return{document:b,lastRequestId:E,invalidated:!0,cancel:x}}),this.invalidate(!0,i),this.queryStore.initQuery({queryId:e,document:b,storePreviousVariables:_,variables:g,isPoll:n===exports.FetchType.poll,isRefetch:n===exports.FetchType.refetch,metadata:c,fetchMoreForQueryId:i}),this.broadcastQueries(),(!_||"cache-and-network"===y)&&(this.queryStore.markQueryResultClient(e,!_),this.invalidate(!0,e,i),this.broadcastQueries(this.localState.shouldForceResolvers(b))),_){if(M=this.fetchRequest({requestId:E,queryId:e,document:b,options:Q,fetchMoreForQueryId:i}).catch(function(t){if(l(t))throw t;var r=P.getQuery(e).lastRequestId;throw E>=(r||1)&&(P.queryStore.markQueryError(e,t,i),P.invalidate(!0,e,i),P.broadcastQueries()),new p({networkError:t})}),"cache-and-network"!==y)return[2,M];M.catch(function(){})}return[2,Promise.resolve({data:w})]}})})},e.prototype.queryListenerForObserver=function(e,r,o){var n=this,i=!1;return function(s,a,c){return t.__awaiter(n,void 0,void 0,function(){var n,l,h,y,f,d,v,b,g,m,Q,w,S,q,k,R,_,E,x,M;return t.__generator(this,function(P){switch(P.label){case 0:if(this.invalidate(!1,e),!s)return[2];if(n=this.getQuery(e).observableQuery,"standby"===(l=n?n.options.fetchPolicy:r.fetchPolicy))return[2];if(h=n?n.options.errorPolicy:r.errorPolicy,y=n?n.getLastResult():null,f=n?n.getLastError():null,d=!a&&null!=s.previousVariables||"cache-only"===l||"cache-and-network"===l,v=Boolean(y&&s.networkStatus!==y.networkStatus),b=h&&(f&&f.graphQLErrors)!==s.graphQLErrors&&"none"!==h,!(!u(s.networkStatus)||v&&r.notifyOnNetworkStatusChange||d))return[3,8];if((!h||"none"===h)&&s.graphQLErrors&&s.graphQLErrors.length>0||s.networkError){if(g=new p({graphQLErrors:s.graphQLErrors,networkError:s.networkError}),i=!0,o.error)try{o.error(g)}catch(e){setTimeout(function(){throw e},0)}else setTimeout(function(){throw g},0);return[2]}P.label=1;case 1:if(P.trys.push([1,7,,8]),m=void 0,Q=void 0,a?("no-cache"!==l&&"network-only"!==l&&this.setQuery(e,function(){return{newData:null}}),m=a.result,Q=!a.complete||!1):y&&y.data&&!b?(m=y.data,Q=!1):(w=this.getQuery(e).document,S=this.dataStore.getCache().diff({query:w,variables:s.previousVariables||s.variables,optimistic:!0}),m=S.result,Q=!S.complete),q=void 0,q=Q&&"cache-only"!==l?{data:y&&y.data,loading:u(s.networkStatus),networkStatus:s.networkStatus,stale:!0}:{data:m,loading:u(s.networkStatus),networkStatus:s.networkStatus,stale:!1},"all"===h&&s.graphQLErrors&&s.graphQLErrors.length>0&&(q.errors=s.graphQLErrors),!o.next)return[3,6];if(!i&&n&&!n.isDifferentFromLastResult(q))return[3,6];P.label=2;case 2:return P.trys.push([2,5,,6]),c?(k=r.query,R=r.variables,_=r.context,[4,this.localState.runResolvers({document:k,remoteResult:q,context:_,variables:R,onlyRunForcedResolvers:c})]):[3,4];case 3:E=P.sent(),q=t.__assign({},q,E),P.label=4;case 4:return o.next(q),[3,6];case 5:return x=P.sent(),setTimeout(function(){throw x},0),[3,6];case 6:return i=!1,[3,8];case 7:return M=P.sent(),i=!0,o.error&&o.error(new p({networkError:M})),[2];case 8:return[2]}})})}},e.prototype.watchQuery=function(e,o){void 0===o&&(o=!0),i.invariant("standby"!==e.fetchPolicy);var n=r.getQueryDefinition(e.query);if(n.variableDefinitions&&n.variableDefinitions.length){var s=r.getDefaultValues(n);e.variables=r.assign({},s,e.variables)}void 0===e.notifyOnNetworkStatusChange&&(e.notifyOnNetworkStatusChange=!1);var a=t.__assign({},e);return new f({queryManager:this,options:a,shouldSubscribe:o})},e.prototype.query=function(e){var t=this;return i.invariant(e.query),i.invariant("Document"===e.query.kind),i.invariant(!e.returnPartialData),i.invariant(!e.pollInterval),new Promise(function(r,o){var n=t.watchQuery(e,!1);t.fetchQueryRejectFns.set("query:"+n.queryId,o),n.result().then(r,o).then(function(){return t.fetchQueryRejectFns.delete("query:"+n.queryId)})})},e.prototype.generateQueryId=function(){var e=this.idCounter.toString();return this.idCounter++,e},e.prototype.stopQueryInStore=function(e){this.stopQueryInStoreNoBroadcast(e),this.broadcastQueries()},e.prototype.stopQueryInStoreNoBroadcast=function(e){this.stopPollingQuery(e),this.queryStore.stopQuery(e),this.invalidate(!0,e)},e.prototype.addQueryListener=function(e,t){this.setQuery(e,function(e){var r=e.listeners;return{listeners:(void 0===r?[]:r).concat([t]),invalidated:!1}})},e.prototype.updateQueryWatch=function(e,t,r){var o=this,n=this.getQuery(e).cancel;n&&n();return this.dataStore.getCache().watch({query:t,variables:r.variables,optimistic:!0,previousResult:function(){var t=null,r=o.getQuery(e).observableQuery;if(r){var n=r.getLastResult();n&&(t=n.data)}return t},callback:function(t){o.setQuery(e,function(){return{invalidated:!0,newData:t}})}})},e.prototype.addObservableQuery=function(e,t){this.setQuery(e,function(){return{observableQuery:t}});var o=r.getQueryDefinition(t.options.query);if(o.name&&o.name.value){var n=o.name.value;this.queryIdsByName[n]=this.queryIdsByName[n]||[],this.queryIdsByName[n].push(t.queryId)}},e.prototype.removeObservableQuery=function(e){var t=this.getQuery(e),o=t.observableQuery,n=t.cancel;if(n&&n(),o){var i=r.getQueryDefinition(o.options.query),s=i.name?i.name.value:null;this.setQuery(e,function(){return{observableQuery:null}}),s&&(this.queryIdsByName[s]=this.queryIdsByName[s].filter(function(e){return!(o.queryId===e)}))}},e.prototype.clearStore=function(){this.fetchQueryRejectFns.forEach(function(e){e(new Error("Store reset while query was in flight(not completed in link chain)"))});var e=[];return this.queries.forEach(function(t,r){t.observableQuery&&e.push(r)}),this.queryStore.reset(e),this.mutationStore.reset(),this.dataStore.reset()},e.prototype.resetStore=function(){var e=this;return this.clearStore().then(function(){return e.reFetchObservableQueries()})},e.prototype.reFetchObservableQueries=function(e){var t=this.getObservableQueryPromises(e);return this.broadcastQueries(),Promise.all(t)},e.prototype.startQuery=function(e,t,r){return this.addQueryListener(e,r),this.fetchQuery(e,t).catch(function(){}),e},e.prototype.startGraphQLSubscription=function(e){var n,i=this,s=e.query,a=!(e.fetchPolicy&&"no-cache"===e.fetchPolicy),u=this.dataStore.getCache().transformDocument(s),l=r.assign({},r.getDefaultValues(r.getOperationDefinition(s)),e.variables),h=l,y=[],f=this.localState.clientQuery(u);return new c(function(e){if(y.push(e),1===y.length){var s=0,d=!1,v={next:function(e){return t.__awaiter(i,void 0,void 0,function(){var o;return t.__generator(this,function(t){switch(t.label){case 0:return s+=1,o=e,f&&r.hasDirectives(["client"],f)?[4,this.localState.runResolvers({document:f,remoteResult:e,context:{},variables:h})]:[3,2];case 1:o=t.sent(),t.label=2;case 2:return a&&(this.dataStore.markSubscriptionResult(o,u,h),this.broadcastQueries()),y.forEach(function(e){r.graphQLResultHasError(o)&&e.error?e.error(new p({graphQLErrors:o.errors})):e.next&&e.next(o),s-=1}),0===s&&d&&v.complete(),[2]}})})},error:function(e){y.forEach(function(t){t.error&&t.error(e)})},complete:function(){0===s&&y.forEach(function(e){e.complete&&e.complete()}),d=!0}};t.__awaiter(i,void 0,void 0,function(){var e,i,s,a;return t.__generator(this,function(t){switch(t.label){case 0:return r.hasClientExports(u)?[4,this.localState.addExportedVariables(u,l)]:[3,2];case 1:return i=t.sent(),[3,3];case 2:i=l,t.label=3;case 3:return e=i,(s=this.localState.serverQuery(u))?(a=this.buildOperationForLink(s,e),n=o.execute(this.link,a).subscribe(v)):n=c.of({data:{}}).subscribe(v),[2]}})})}return function(){0===(y=y.filter(function(t){return t!==e})).length&&n&&n.unsubscribe()}})},e.prototype.stopQuery=function(e){this.stopQueryNoBroadcast(e),this.broadcastQueries()},e.prototype.stopQueryNoBroadcast=function(e){this.stopQueryInStoreNoBroadcast(e),this.removeQuery(e)},e.prototype.removeQuery=function(e){var t=this.getQuery(e).subscriptions;this.fetchQueryRejectFns.delete("query:"+e),this.fetchQueryRejectFns.delete("fetchRequest:"+e),t.forEach(function(e){return e.unsubscribe()}),this.queries.delete(e)},e.prototype.getCurrentQueryResult=function(e,t){void 0===t&&(t=!0);var r=e.options,o=r.variables,n=r.query,i=r.fetchPolicy,s=e.getLastResult(),a=this.getQuery(e.queryId).newData;if(a&&a.complete)return{data:a.result,partial:!1};if("no-cache"===i||"network-only"===i)return{data:void 0,partial:!1};try{return{data:this.dataStore.getCache().read({query:n,variables:o,previousResult:s?s.data:void 0,optimistic:t})||void 0,partial:!1}}catch(e){return{data:void 0,partial:!0}}},e.prototype.getQueryWithPreviousResult=function(e){var t;if("string"==typeof e){var r=this.getQuery(e).observableQuery;i.invariant(r),t=r}else t=e;var o=t.options,n=o.variables,s=o.query;return{previousResult:this.getCurrentQueryResult(t,!1).data,variables:n,document:s}},e.prototype.broadcastQueries=function(e){var t=this;void 0===e&&(e=!1),this.onBroadcast(),this.queries.forEach(function(r,o){r.invalidated&&r.listeners&&r.listeners.filter(function(e){return!!e}).forEach(function(n){n(t.queryStore.get(o),r.newData,e)})})},e.prototype.getLocalState=function(){return this.localState},e.prototype.getObservableQueryPromises=function(e){var t=this,r=[];return this.queries.forEach(function(o,n){var i=o.observableQuery;if(i){var s=i.options.fetchPolicy;i.resetLastResults(),"cache-only"===s||!e&&"standby"===s||r.push(i.refetch()),t.setQuery(n,function(){return{newData:null}}),t.invalidate(!0,n)}}),r},e.prototype.fetchRequest=function(e){var n,i,s=this,a=e.requestId,u=e.queryId,l=e.document,h=e.options,y=e.fetchMoreForQueryId,f=h.variables,d=h.context,v=h.errorPolicy,b=void 0===v?"none":v,g=h.fetchPolicy;return new Promise(function(e,h){var v,m={},Q=s.localState.clientQuery(l),w=s.localState.serverQuery(l);if(w){var S=s.buildOperationForLink(w,f,t.__assign({},d,{forceFetch:!s.queryDeduplication}));m=S.context,v=o.execute(s.deduplicator,S)}else m=s.prepareContext(d),v=c.of({data:{}});s.fetchQueryRejectFns.set("fetchRequest:"+u,h);var q=!1,k=!0,R={next:function(e){return t.__awaiter(s,void 0,void 0,function(){var o,s;return t.__generator(this,function(t){switch(t.label){case 0:return k=!0,o=e,s=this.getQuery(u).lastRequestId,a>=(s||1)?Q&&r.hasDirectives(["client"],Q)?[4,this.localState.runResolvers({document:Q,remoteResult:e,context:m,variables:f}).catch(function(t){return k=!1,h(t),e})]:[3,2]:[3,3];case 1:o=t.sent(),t.label=2;case 2:if("no-cache"!==g)try{this.dataStore.markQueryResult(o,l,f,y,"ignore"===b||"all"===b)}catch(e){return k=!1,h(e),[2]}else this.setQuery(u,function(){return{newData:{result:o.data,complete:!0}}});this.queryStore.markQueryResult(u,o,y),this.invalidate(!0,u,y),this.broadcastQueries(),t.label=3;case 3:if(o.errors&&"none"===b)return k=!1,h(new p({graphQLErrors:o.errors})),[2];if("all"===b&&(i=o.errors),y||"no-cache"===g)n=o.data;else try{n=this.dataStore.getCache().read({variables:f,query:l,optimistic:!1})}catch(e){}return k=!1,q&&R.complete(),[2]}})})},error:function(e){s.fetchQueryRejectFns.delete("fetchRequest:"+u),s.setQuery(u,function(e){return{subscriptions:e.subscriptions.filter(function(e){return e!==_})}}),h(e)},complete:function(){k||(s.fetchQueryRejectFns.delete("fetchRequest:"+u),s.setQuery(u,function(e){return{subscriptions:e.subscriptions.filter(function(e){return e!==_})}}),e({data:n,errors:i,loading:!1,networkStatus:exports.NetworkStatus.ready,stale:!1})),q=!0}},_=v.subscribe(R);s.setQuery(u,function(e){return{subscriptions:e.subscriptions.concat([_])}})}).catch(function(e){throw s.fetchQueryRejectFns.delete("fetchRequest:"+u),e})},e.prototype.refetchQueryByName=function(e){var t=this,r=this.queryIdsByName[e];if(void 0!==r)return Promise.all(r.map(function(e){return t.getQuery(e).observableQuery}).filter(function(e){return!!e}).map(function(e){return e.refetch()}))},e.prototype.generateRequestId=function(){var e=this.idCounter;return this.idCounter++,e},e.prototype.getQuery=function(e){return this.queries.get(e)||{listeners:[],invalidated:!1,document:null,newData:null,lastRequestId:null,observableQuery:null,subscriptions:[]}},e.prototype.setQuery=function(e,r){var o=this.getQuery(e),n=t.__assign({},o,r(o));this.queries.set(e,n)},e.prototype.invalidate=function(e,t,r){t&&this.setQuery(t,function(){return{invalidated:e}}),r&&this.setQuery(r,function(){return{invalidated:e}})},e.prototype.buildOperationForLink=function(e,t,o){var n=this.dataStore.getCache();return{query:n.transformForLink?n.transformForLink(e):e,variables:t,operationName:r.getOperationName(e)||void 0,context:this.prepareContext(o)}},e.prototype.prepareContext=function(e){void 0===e&&(e={});var r=this.localState.prepareContext(e);return t.__assign({},r,{clientAwareness:this.clientAwareness})},e.prototype.checkInFlight=function(e){var t=this.queryStore.get(e);return t&&t.networkStatus!==exports.NetworkStatus.ready&&t.networkStatus!==exports.NetworkStatus.error},e.prototype.startPollingQuery=function(e,r,o){var n=e.pollInterval;return i.invariant(n),this.ssrMode||(this.pollingInfoByQueryId.set(r,{interval:n,lastPollTimeMs:Date.now()-10,options:t.__assign({},e,{fetchPolicy:"network-only"})}),o&&this.addQueryListener(r,o),this.schedulePoll(n)),r},e.prototype.stopPollingQuery=function(e){this.pollingInfoByQueryId.delete(e)},e.prototype.schedulePoll=function(e){var t=this,r=Date.now();if(this.nextPoll){if(!(e<this.nextPoll.time-r))return;clearTimeout(this.nextPoll.timeout)}this.nextPoll={time:r+e,timeout:setTimeout(function(){t.nextPoll=null;var e=1/0;t.pollingInfoByQueryId.forEach(function(r,o){if(r.interval<e&&(e=r.interval),!t.checkInFlight(o)&&Date.now()-r.lastPollTimeMs>=r.interval){var n=function(){r.lastPollTimeMs=Date.now()};t.fetchQuery(o,r.options,exports.FetchType.poll).then(n,n)}}),isFinite(e)&&t.schedulePoll(e)},e)}},e}(),w=function(){function e(e){this.cache=e}return e.prototype.getCache=function(){return this.cache},e.prototype.markQueryResult=function(e,t,o,n,i){void 0===i&&(i=!1);var s=!r.graphQLResultHasError(e);i&&r.graphQLResultHasError(e)&&e.data&&(s=!0),!n&&s&&this.cache.write({result:e.data,dataId:"ROOT_QUERY",query:t,variables:o})},e.prototype.markSubscriptionResult=function(e,t,o){r.graphQLResultHasError(e)||this.cache.write({result:e.data,dataId:"ROOT_SUBSCRIPTION",query:t,variables:o})},e.prototype.markMutationInit=function(e){var t=this;if(e.optimisticResponse){var r;r="function"==typeof e.optimisticResponse?e.optimisticResponse(e.variables):e.optimisticResponse;this.cache.recordOptimisticTransaction(function(o){var n=t.cache;t.cache=o;try{t.markMutationResult({mutationId:e.mutationId,result:{data:r},document:e.document,variables:e.variables,updateQueries:e.updateQueries,update:e.update})}finally{t.cache=n}},e.mutationId)}},e.prototype.markMutationResult=function(e){var t=this;if(!r.graphQLResultHasError(e.result)){var o=[];o.push({result:e.result.data,dataId:"ROOT_MUTATION",query:e.document,variables:e.variables}),e.updateQueries&&Object.keys(e.updateQueries).filter(function(t){return e.updateQueries[t]}).forEach(function(n){var i=e.updateQueries[n],s=i.query,a=i.updater,u=t.cache.diff({query:s.document,variables:s.variables,returnPartialData:!0,optimistic:!1}),c=u.result;if(u.complete){var l=r.tryFunctionOrLogError(function(){return a(c,{mutationResult:e.result,queryName:r.getOperationName(s.document)||void 0,queryVariables:s.variables})});l&&o.push({result:l,dataId:"ROOT_QUERY",query:s.document,variables:s.variables})}}),this.cache.performTransaction(function(e){o.forEach(function(t){return e.write(t)})});var n=e.update;n&&this.cache.performTransaction(function(t){r.tryFunctionOrLogError(function(){return n(t,e.result)})})}},e.prototype.markMutationComplete=function(e){var t=e.mutationId;e.optimisticResponse&&this.cache.removeOptimistic(t)},e.prototype.markUpdateQueryResult=function(e,t,r){this.cache.write({result:r,dataId:"ROOT_QUERY",variables:t,query:e})},e.prototype.reset=function(){return this.cache.reset()},e}(),S="2.5.1",q=!1,k=function(){function e(e){var t=this;this.defaultOptions={},this.resetStoreCallbacks=[],this.clearStoreCallbacks=[],this.clientAwareness={};var n=e.cache,s=e.ssrMode,a=void 0!==s&&s,u=e.ssrForceFetchDelay,c=void 0===u?0:u,l=e.connectToDevTools,h=e.queryDeduplication,p=void 0===h||h,y=e.defaultOptions,f=e.resolvers,d=e.typeDefs,v=e.fragmentMatcher,b=e.name,g=e.version,Q=e.link;if(!Q&&f&&(Q=o.ApolloLink.empty()),!Q||!n)throw new i.InvariantError;var q=new Map,k=new o.ApolloLink(function(e,t){var o=q.get(e.query);return o||(o=r.removeConnectionDirectiveFromDocument(e.query),q.set(e.query,o),q.set(o,o)),e.query=o,t(e)});this.link=k.concat(Q),this.cache=n,this.store=new w(n),this.disableNetworkFetches=a||c>0,this.queryDeduplication=p,this.ssrMode=a,this.defaultOptions=y||{},this.typeDefs=d,c&&setTimeout(function(){return t.disableNetworkFetches=!1},c),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!==l&&(l&&"undefined"!=typeof window)&&(window.__APOLLO_CLIENT__=this),this.version=S,b&&(this.clientAwareness.name=b),g&&(this.clientAwareness.version=g),this.localState=new m({cache:n,client:this,resolvers:f,fragmentMatcher:v})}return e.prototype.stop=function(){this.queryManager&&this.queryManager.stop()},e.prototype.watchQuery=function(e){return this.defaultOptions.watchQuery&&(e=t.__assign({},this.defaultOptions.watchQuery,e)),!this.disableNetworkFetches||"network-only"!==e.fetchPolicy&&"cache-and-network"!==e.fetchPolicy||(e=t.__assign({},e,{fetchPolicy:"cache-first"})),this.initQueryManager().watchQuery(e)},e.prototype.query=function(e){return this.defaultOptions.query&&(e=t.__assign({},this.defaultOptions.query,e)),i.invariant("cache-and-network"!==e.fetchPolicy),this.disableNetworkFetches&&"network-only"===e.fetchPolicy&&(e=t.__assign({},e,{fetchPolicy:"cache-first"})),this.initQueryManager().query(e)},e.prototype.mutate=function(e){return this.defaultOptions.mutate&&(e=t.__assign({},this.defaultOptions.mutate,e)),this.initQueryManager().mutate(e)},e.prototype.subscribe=function(e){return this.initQueryManager().startGraphQLSubscription(e)},e.prototype.readQuery=function(e,t){return void 0===t&&(t=!1),this.initProxy().readQuery(e,t)},e.prototype.readFragment=function(e,t){return void 0===t&&(t=!1),this.initProxy().readFragment(e,t)},e.prototype.writeQuery=function(e){var t=this.initProxy().writeQuery(e);return this.initQueryManager().broadcastQueries(),t},e.prototype.writeFragment=function(e){var t=this.initProxy().writeFragment(e);return this.initQueryManager().broadcastQueries(),t},e.prototype.writeData=function(e){var t=this.initProxy().writeData(e);return this.initQueryManager().broadcastQueries(),t},e.prototype.__actionHookForDevTools=function(e){this.devToolsHookCb=e},e.prototype.__requestRaw=function(e){return o.execute(this.link,e)},e.prototype.initQueryManager=function(){var e=this;return this.queryManager||(this.queryManager=new Q({link:this.link,store:this.store,queryDeduplication:this.queryDeduplication,ssrMode:this.ssrMode,clientAwareness:this.clientAwareness,localState:this.localState,onBroadcast:function(){e.devToolsHookCb&&e.devToolsHookCb({action:{},state:{queries:e.queryManager?e.queryManager.queryStore.getStore():{},mutations:e.queryManager?e.queryManager.mutationStore.getStore():{}},dataWithOptimisticResults:e.cache.extract(!0)})}})),this.queryManager},e.prototype.resetStore=function(){var e=this;return Promise.resolve().then(function(){return e.queryManager?e.queryManager.clearStore():Promise.resolve(null)}).then(function(){return Promise.all(e.resetStoreCallbacks.map(function(e){return e()}))}).then(function(){return e.queryManager&&e.queryManager.reFetchObservableQueries?e.queryManager.reFetchObservableQueries():Promise.resolve(null)})},e.prototype.clearStore=function(){var e=this,t=this.queryManager;return Promise.resolve().then(function(){return Promise.all(e.clearStoreCallbacks.map(function(e){return e()}))}).then(function(){return t?t.clearStore():Promise.resolve(null)})},e.prototype.onResetStore=function(e){var t=this;return this.resetStoreCallbacks.push(e),function(){t.resetStoreCallbacks=t.resetStoreCallbacks.filter(function(t){return t!==e})}},e.prototype.onClearStore=function(e){var t=this;return this.clearStoreCallbacks.push(e),function(){t.clearStoreCallbacks=t.clearStoreCallbacks.filter(function(t){return t!==e})}},e.prototype.reFetchObservableQueries=function(e){return this.queryManager?this.queryManager.reFetchObservableQueries(e):Promise.resolve(null)},e.prototype.extract=function(e){return this.initProxy().extract(e)},e.prototype.restore=function(e){return this.initProxy().restore(e)},e.prototype.addResolvers=function(e){this.localState.addResolvers(e)},e.prototype.setResolvers=function(e){this.localState.setResolvers(e)},e.prototype.getResolvers=function(){return this.localState.getResolvers()},e.prototype.setLocalStateFragmentMatcher=function(e){this.localState.setFragmentMatcher(e)},e.prototype.initProxy=function(){return this.proxy||(this.initQueryManager(),this.proxy=this.cache),this.proxy},e}();exports.default=k,exports.ApolloClient=k,exports.ObservableQuery=f,exports.isApolloError=l,exports.ApolloError=p; | ||
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("tslib"),r=require("apollo-utilities"),o=require("apollo-link"),n=e(require("symbol-observable")),s=require("ts-invariant"),i=require("graphql/language/visitor");function a(e){return e<7}!function(e){e[e.loading=1]="loading",e[e.setVariables=2]="setVariables",e[e.fetchMore=3]="fetchMore",e[e.refetch=4]="refetch",e[e.poll=6]="poll",e[e.ready=7]="ready",e[e.error=8]="error"}(exports.NetworkStatus||(exports.NetworkStatus={}));var u=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t.__extends(r,e),r.prototype[n]=function(){return this},r.prototype["@@observable"]=function(){return this},r}(o.Observable);function c(e){return e.hasOwnProperty("graphQLErrors")}var l=function(e){var t="";return Array.isArray(e.graphQLErrors)&&0!==e.graphQLErrors.length&&e.graphQLErrors.forEach(function(e){var r=e?e.message:"Error message not found.";t+="GraphQL error: "+r+"\n"}),e.networkError&&(t+="Network error: "+e.networkError.message+"\n"),t=t.replace(/\n$/,"")},h=function(e){function r(t){var o=t.graphQLErrors,n=t.networkError,s=t.errorMessage,i=t.extraInfo,a=e.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 t.__extends(r,e),r}(Error);!function(e){e[e.normal=1]="normal",e[e.refetch=2]="refetch",e[e.poll=3]="poll"}(exports.FetchType||(exports.FetchType={}));var p=function(e,t){return void 0===t&&(t="none"),e&&(e.graphQLErrors&&e.graphQLErrors.length>0&&"none"===t||e.networkError)},y=function(e){function o(t){var o=t.queryManager,n=t.options,s=t.shouldSubscribe,i=void 0===s||s,a=e.call(this,function(e){return a.onSubscribe(e)})||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 t.__extends(o,e),o.prototype.result=function(){var e=this;return new Promise(function(t,r){var o={next:function(r){t(r),e.observers.delete(o),e.observers.size||e.queryManager.removeQuery(e.queryId),setTimeout(function(){n.unsubscribe()},0)},error:r},n=e.subscribe(o)})},o.prototype.currentResult=function(){var e=this.getCurrentResult();return void 0===e.data&&(e.data={}),e},o.prototype.getCurrentResult=function(){if(this.isTornDown){var e=this.lastResult;return{data:!this.lastError&&e&&e.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=t.__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=t.__assign({},o,{stale:!1}),this.lastResultSnapshot=this.queryManager.assumeImmutableResults?this.lastResult:r.cloneDeep(this.lastResult)),t.__assign({},o,{partial:i})},o.prototype.isDifferentFromLastResult=function(e){var t=this.lastResultSnapshot;return!(t&&e&&t.networkStatus===e.networkStatus&&t.stale===e.stale&&r.isEqual(t.data,e.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(e){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,e)||(this.variables=t.__assign({},this.variables,e)),r.isEqual(this.options.variables,this.variables)||(this.options.variables=t.__assign({},this.options.variables,this.variables)),this.queryManager.fetchQuery(this.queryId,t.__assign({},this.options,{fetchPolicy:o}),exports.FetchType.refetch))},o.prototype.fetchMore=function(e){var r=this;s.invariant(e.updateQuery,4);var o=t.__assign({},e.query?e:t.__assign({},this.options,e,{variables:t.__assign({},this.variables,e.variables)}),{fetchPolicy:"network-only"});return this.queryManager.fetchQuery(this.queryManager.generateQueryId(),o,exports.FetchType.normal,this.queryId).then(function(t){return r.updateQuery(function(r){return e.updateQuery(r,{fetchMoreResult:t.data,variables:o.variables})}),t})},o.prototype.subscribeToMore=function(e){var t=this,r=this.queryManager.startGraphQLSubscription({query:e.document,variables:e.variables}).subscribe({next:function(r){e.updateQuery&&t.updateQuery(function(t,o){var n=o.variables;return e.updateQuery(t,{subscriptionData:r,variables:n})})},error:function(t){e.onError&&e.onError(t)}});return this.subscriptions.add(r),function(){t.subscriptions.delete(r)&&r.unsubscribe()}},o.prototype.setOptions=function(e){var r=this.options.fetchPolicy;this.options=t.__assign({},this.options,e),e.pollInterval?this.startPolling(e.pollInterval):0===e.pollInterval&&this.stopPolling();var o=e.fetchPolicy;return this.setVariables(this.options.variables,r!==o&&("cache-only"===r||"standby"===r||"network-only"===o),e.fetchResults)},o.prototype.setVariables=function(e,t,o){return void 0===t&&(t=!1),void 0===o&&(o=!0),this.isTornDown=!1,e=e||this.variables,!t&&r.isEqual(e,this.variables)?this.observers.size&&o?this.result():Promise.resolve():(this.variables=this.options.variables=e,this.observers.size?this.queryManager.fetchQuery(this.queryId,this.options):Promise.resolve())},o.prototype.updateQuery=function(e){var t=this.queryManager.getQueryWithPreviousResult(this.queryId),o=t.previousResult,n=t.variables,s=t.document,i=r.tryFunctionOrLogError(function(){return e(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(e){d(this),this.options.pollInterval=e,this.queryManager.startPollingQuery(this.options,this.queryId)},o.prototype.onSubscribe=function(e){var t=this,r=!this.observers.size;return this.observers.add(e),e.next&&this.lastResult&&e.next(this.lastResult),e.error&&this.lastError&&e.error(this.lastError),r&&this.setUpQuery(),function(){t.observers.delete(e)&&!t.observers.size&&t.tearDownQuery()}},o.prototype.setUpQuery=function(){var e=this;this.shouldSubscribe&&this.queryManager.addObservableQuery(this.queryId,this),this.options.pollInterval&&(d(this),this.queryManager.startPollingQuery(this.options,this.queryId));var t={next:function(t){e.lastResult=t,e.lastResultSnapshot=e.queryManager.assumeImmutableResults?t:r.cloneDeep(t),f(e.observers,"next",t)},error:function(t){e.lastError=t,f(e.observers,"error",t)}};this.queryManager.startQuery(this.queryId,this.options,this.queryManager.queryListenerForObserver(this.queryId,this.options,t))},o.prototype.tearDownQuery=function(){this.isTornDown=!0,this.queryManager.stopPollingQuery(this.queryId),this.subscriptions.forEach(function(e){return e.unsubscribe()}),this.subscriptions.clear(),this.queryManager.removeObservableQuery(this.queryId),this.queryManager.stopQuery(this.queryId),this.observers.clear()},o}(u);function f(e,t,r){var o=[];e.forEach(function(e){return e[t]&&o.push(e)}),o.forEach(function(e){return e[t](r)})}function d(e){var t=e.options.fetchPolicy;s.invariant("cache-first"!==t&&"cache-only"!==t,5)}var v=function(){function e(){this.store={}}return e.prototype.getStore=function(){return this.store},e.prototype.get=function(e){return this.store[e]},e.prototype.initMutation=function(e,t,r){this.store[e]={mutation:t,variables:r||{},loading:!0,error:null}},e.prototype.markMutationError=function(e,t){var r=this.store[e];r&&(r.loading=!1,r.error=t)},e.prototype.markMutationResult=function(e){var t=this.store[e];t&&(t.loading=!1,t.error=null)},e.prototype.reset=function(){this.store={}},e}(),b=function(){function e(){this.store={}}return e.prototype.getStore=function(){return this.store},e.prototype.get=function(e){return this.store[e]},e.prototype.initQuery=function(e){var t=this.store[e.queryId];if(t&&t.document!==e.document&&!r.isEqual(t.document,e.document))throw new s.InvariantError(19);var o,n=!1,i=null;e.storePreviousVariables&&t&&t.networkStatus!==exports.NetworkStatus.loading&&(r.isEqual(t.variables,e.variables)||(n=!0,i=t.variables)),o=n?exports.NetworkStatus.setVariables:e.isPoll?exports.NetworkStatus.poll:e.isRefetch?exports.NetworkStatus.refetch:exports.NetworkStatus.loading;var a=[];t&&t.graphQLErrors&&(a=t.graphQLErrors),this.store[e.queryId]={document:e.document,variables:e.variables,previousVariables:i,networkError:null,graphQLErrors:a,networkStatus:o,metadata:e.metadata},"string"==typeof e.fetchMoreForQueryId&&this.store[e.fetchMoreForQueryId]&&(this.store[e.fetchMoreForQueryId].networkStatus=exports.NetworkStatus.fetchMore)},e.prototype.markQueryResult=function(e,t,r){this.store&&this.store[e]&&(this.store[e].networkError=null,this.store[e].graphQLErrors=t.errors&&t.errors.length?t.errors:[],this.store[e].previousVariables=null,this.store[e].networkStatus=exports.NetworkStatus.ready,"string"==typeof r&&this.store[r]&&(this.store[r].networkStatus=exports.NetworkStatus.ready))},e.prototype.markQueryError=function(e,t,r){this.store&&this.store[e]&&(this.store[e].networkError=t,this.store[e].networkStatus=exports.NetworkStatus.error,"string"==typeof r&&this.markQueryResultClient(r,!0))},e.prototype.markQueryResultClient=function(e,t){this.store&&this.store[e]&&(this.store[e].networkError=null,this.store[e].previousVariables=null,this.store[e].networkStatus=t?exports.NetworkStatus.ready:exports.NetworkStatus.loading)},e.prototype.stopQuery=function(e){delete this.store[e]},e.prototype.reset=function(e){var r=this;this.store=Object.keys(this.store).filter(function(t){return e.indexOf(t)>-1}).reduce(function(e,o){return e[o]=t.__assign({},r.store[o],{networkStatus:exports.NetworkStatus.loading}),e},{})},e}();function g(e){return e.charAt(0).toUpperCase()+e.slice(1)}var m=function(){function e(e){var t=e.cache,r=e.client,o=e.resolvers,n=e.fragmentMatcher;this.cache=t,r&&(this.client=r),o&&this.addResolvers(o),n&&this.setFragmentMatcher(n)}return e.prototype.addResolvers=function(e){var t=this;this.resolvers=this.resolvers||{},Array.isArray(e)?e.forEach(function(e){t.resolvers=r.mergeDeep(t.resolvers,e)}):this.resolvers=r.mergeDeep(this.resolvers,e)},e.prototype.setResolvers=function(e){this.resolvers={},this.addResolvers(e)},e.prototype.getResolvers=function(){return this.resolvers||{}},e.prototype.runResolvers=function(e){var r=e.document,o=e.remoteResult,n=e.context,s=e.variables,i=e.onlyRunForcedResolvers,a=void 0!==i&&i;return t.__awaiter(this,void 0,void 0,function(){return t.__generator(this,function(e){return r?[2,this.resolveDocument(r,o.data,n,s,this.fragmentMatcher,a).then(function(e){return t.__assign({},o,{data:e.result})})]:[2,o]})})},e.prototype.setFragmentMatcher=function(e){this.fragmentMatcher=e},e.prototype.getFragmentMatcher=function(){return this.fragmentMatcher},e.prototype.clientQuery=function(e){return r.hasDirectives(["client"],e)&&this.resolvers?e:null},e.prototype.serverQuery=function(e){return this.resolvers?r.removeClientSetsFromDocument(e):e},e.prototype.prepareContext=function(e){void 0===e&&(e={});var r=this.cache;return t.__assign({},e,{cache:r,getCacheKey:function(e){if(r.config)return r.config.dataIdFromObject(e);s.invariant(!1,17)}})},e.prototype.addExportedVariables=function(e,r,o){return void 0===r&&(r={}),void 0===o&&(o={}),t.__awaiter(this,void 0,void 0,function(){return t.__generator(this,function(n){return e?[2,this.resolveDocument(e,this.buildRootValueFromCache(e,r)||{},this.prepareContext(o),r).then(function(e){return t.__assign({},r,e.exportedVariables)})]:[2,t.__assign({},r)]})})},e.prototype.shouldForceResolvers=function(e){var t=!1;return i.visit(e,{Directive:{enter:function(e){if("client"===e.name.value&&e.arguments&&(t=e.arguments.some(function(e){return"always"===e.name.value&&"BooleanValue"===e.value.kind&&!0===e.value.value})))return i.BREAK}}}),t},e.prototype.shouldForceResolver=function(e){return this.shouldForceResolvers(e)},e.prototype.buildRootValueFromCache=function(e,t){return this.cache.diff({query:r.buildQueryFromSelectionSet(e),variables:t,optimistic:!1}).result},e.prototype.resolveDocument=function(e,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),t.__awaiter(this,void 0,void 0,function(){var u,c,l,h,p,y,f,d,v;return t.__generator(this,function(b){return u=r.getMainDefinition(e),c=r.getFragmentDefinitions(e),l=r.createFragmentMap(c),h=u.operation,p=h?g(h):"Query",f=(y=this).cache,d=y.client,v={fragmentMap:l,context:t.__assign({},n,{cache:f,client:d}),variables:s,fragmentMatcher:i,defaultOperationType:p,exportedVariables:{},onlyRunForcedResolvers:a},[2,this.resolveSelectionSet(u.selectionSet,o,v).then(function(e){return{result:e,exportedVariables:v.exportedVariables}})]})})},e.prototype.resolveSelectionSet=function(e,o,n){return t.__awaiter(this,void 0,void 0,function(){var i,a,u,c,l,h=this;return t.__generator(this,function(p){return i=n.fragmentMap,a=n.context,u=n.variables,c=[o],l=function(e){return t.__awaiter(h,void 0,void 0,function(){var l,h;return t.__generator(this,function(t){return r.shouldInclude(e,u)?r.isField(e)?[2,this.resolveField(e,o,n).then(function(t){var o;void 0!==t&&c.push(((o={})[r.resultKeyNameFromField(e)]=t,o))})]:(r.isInlineFragment(e)?l=e:(l=i[e.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(e){c.push(e)})]:[2]):[2]})})},[2,Promise.all(e.selections.map(l)).then(function(){return r.mergeDeepArray(c)})]})})},e.prototype.resolveField=function(e,o,n){return t.__awaiter(this,void 0,void 0,function(){var s,i,a,u,c,l,h,p,y,f=this;return t.__generator(this,function(t){return s=n.variables,i=e.name.value,a=r.resultKeyNameFromField(e),u=i!==a,c=o[a]||o[i],l=Promise.resolve(c),n.onlyRunForcedResolvers&&!this.shouldForceResolver(e)||(h=o.__typename||n.defaultOperationType,(p=this.resolvers&&this.resolvers[h])&&(y=p[u?i:a])&&(l=Promise.resolve(y(o,r.argumentsObjectFromField(e,s),n.context,{field:e})))),[2,l.then(function(t){return void 0===t&&(t=c),e.directives&&e.directives.forEach(function(e){"export"===e.name.value&&e.arguments&&e.arguments.forEach(function(e){"as"===e.name.value&&"StringValue"===e.value.kind&&(n.exportedVariables[e.value.value]=t)})}),e.selectionSet?null==t?t:Array.isArray(t)?f.resolveSubSelectedArray(e,t,n):e.selectionSet?f.resolveSelectionSet(e.selectionSet,t,n):void 0:t})]})})},e.prototype.resolveSubSelectedArray=function(e,t,r){var o=this;return Promise.all(t.map(function(t){return null===t?null:Array.isArray(t)?o.resolveSubSelectedArray(e,t,r):e.selectionSet?o.resolveSelectionSet(e.selectionSet,t,r):void 0}))},e}();function Q(e){var t=new Set,r=null;return new u(function(o){return t.add(o),r=r||e.subscribe({next:function(e){t.forEach(function(t){return t.next&&t.next(e)})},error:function(e){t.forEach(function(t){return t.error&&t.error(e)})},complete:function(){t.forEach(function(e){return e.complete&&e.complete()})}}),function(){t.delete(o)&&!t.size&&r&&(r.unsubscribe(),r=null)}})}function w(e,t){return new u(function(r){var o=r.next,n=r.error,s=r.complete,i=0,a=!1,u={next:function(e){++i,new Promise(function(r){r(t(e))}).then(function(e){--i,o&&o.call(r,e),a&&u.complete()},function(e){--i,n&&n.call(r,e)})},error:function(e){n&&n.call(r,e)},complete:function(){a=!0,i||s&&s.call(r)}},c=e.subscribe(u);return function(){return c.unsubscribe()}})}var S=Object.prototype.hasOwnProperty,q=function(){function e(e){var t=e.link,r=e.queryDeduplication,o=void 0!==r&&r,n=e.store,s=e.onBroadcast,i=void 0===s?function(){}:s,a=e.ssrMode,u=void 0!==a&&a,c=e.clientAwareness,l=void 0===c?{}:c,h=e.localState,p=e.assumeImmutableResults;this.mutationStore=new v,this.queryStore=new b,this.clientAwareness={},this.idCounter=1,this.queries=new Map,this.fetchQueryRejectFns=new Map,this.inFlightLinkObservables=new Map,this.pollingInfoByQueryId=new Map,this.nextPoll=null,this.link=t,this.queryDeduplication=o,this.dataStore=n,this.onBroadcast=i,this.clientAwareness=l,this.localState=h||new m({cache:n.getCache()}),this.ssrMode=u,this.assumeImmutableResults=!!p}return e.prototype.stop=function(){var e=this;this.queries.forEach(function(t,r){e.stopQueryNoBroadcast(r)}),this.fetchQueryRejectFns.forEach(function(e){e(new s.InvariantError(6))})},e.prototype.mutate=function(e){var o=e.mutation,n=e.variables,i=e.optimisticResponse,a=e.updateQueries,u=e.refetchQueries,c=void 0===u?[]:u,l=e.awaitRefetchQueries,p=void 0!==l&&l,y=e.update,f=e.errorPolicy,d=void 0===f?"none":f,v=e.fetchPolicy,b=e.context,g=void 0===b?{}:b;return t.__awaiter(this,void 0,void 0,function(){var e,u,l,f=this;return t.__generator(this,function(b){switch(b.label){case 0:return s.invariant(o,7),s.invariant(!v||"no-cache"===v,8),e=this.generateQueryId(),o=this.dataStore.getCache().transformDocument(o),this.setQuery(e,function(){return{document:o}}),n=t.__assign({},r.getDefaultValues(r.getOperationDefinition(o)),n),r.hasClientExports(o)?[4,this.localState.addExportedVariables(o,n,g)]:[3,2];case 1:n=b.sent(),b.label=2;case 2:return u=function(){var e={};return a&&f.queries.forEach(function(t,r){var o=t.observableQuery;if(o){var n=o.queryName;n&&S.call(a,n)&&(e[r]={updater:a[n],query:f.queryStore.get(r)})}}),e},this.mutationStore.initMutation(e,o,n),this.dataStore.markMutationInit({mutationId:e,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,t.__assign({},g,{optimisticResponse:i}),n,!1).subscribe({next:function(t){r.graphQLResultHasError(t)&&"none"===d?b=new h({graphQLErrors:t.errors}):(l.mutationStore.markMutationResult(e),"no-cache"!==v&&l.dataStore.markMutationResult({mutationId:e,result:t,document:o,variables:n,updateQueries:u(),update:y}),f=t)},error:function(t){l.mutationStore.markMutationError(e,t),l.dataStore.markMutationComplete({mutationId:e,optimisticResponse:i}),l.broadcastQueries(),l.setQuery(e,function(){return{document:null}}),a(new h({networkError:t}))},complete:function(){if(b&&l.mutationStore.markMutationError(e,b),l.dataStore.markMutationComplete({mutationId:e,optimisticResponse:i}),l.broadcastQueries(),b)a(b);else{"function"==typeof c&&(c=c(f));var t=[];c.forEach(function(e){if("string"==typeof e)l.queries.forEach(function(r){var o=r.observableQuery;o&&o.queryName===e&&t.push(o.refetch())});else{var r={query:e.query,variables:e.variables,fetchPolicy:"network-only"};e.context&&(r.context=e.context),t.push(l.query(r))}}),Promise.all(p?t:[]).then(function(){l.setQuery(e,function(){return{document:null}}),"ignore"===d&&f&&r.graphQLResultHasError(f)&&delete f.errors,s(f)})}}})})]}})})},e.prototype.fetchQuery=function(e,o,n,s){return t.__awaiter(this,void 0,void 0,function(){var i,a,u,l,p,y,f,d,v,b,g,m,Q,w,S,q,k,R=this;return t.__generator(this,function(_){switch(_.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.dataStore.getCache().transformDocument(o.query),d=t.__assign({},r.getDefaultValues(r.getOperationDefinition(f)),o.variables),r.hasClientExports(f)?[4,this.localState.addExportedVariables(f,d,y)]:[3,2];case 1:d=_.sent(),_.label=2;case 2:if(o=t.__assign({},o,{variables:d}),b="network-only"===l||"no-cache"===l,n!==exports.FetchType.refetch&&"network-only"!==l&&"no-cache"!==l&&(g=this.dataStore.getCache().diff({query:f,variables:d,returnPartialData:!0,optimistic:!1}),m=g.complete,Q=g.result,b=!m||"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(e,f,o),this.setQuery(e,function(){return{document:f,lastRequestId:S,invalidated:!0,cancel:q}}),this.invalidate(!0,s),this.queryStore.initQuery({queryId:e,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(e,!w),this.invalidate(!0,e,s),this.broadcastQueries(this.localState.shouldForceResolvers(f))),w){if(k=this.fetchRequest({requestId:S,queryId:e,document:f,options:o,fetchMoreForQueryId:s}).catch(function(t){throw c(t)?t:(S>=R.getQuery(e).lastRequestId&&(R.queryStore.markQueryError(e,t,s),R.invalidate(!0,e,s),R.broadcastQueries()),new h({networkError:t}))}),"cache-and-network"!==l)return[2,k];k.catch(function(){})}return[2,Promise.resolve({data:v})]}})})},e.prototype.queryListenerForObserver=function(e,r,o){var n=this,s=!1;return function(i,u,c){return t.__awaiter(n,void 0,void 0,function(){var n,l,p,y,f,d,v,b,g,m,Q,w,S,q,k,R,_,E,M,x;return t.__generator(this,function(I){switch(I.label){case 0:if(this.invalidate(!1,e),!i)return[2];if(n=this.getQuery(e).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(g=new h({graphQLErrors:i.graphQLErrors,networkError:i.networkError}),s=!0,o.error)try{o.error(g)}catch(e){setTimeout(function(){throw e},0)}else setTimeout(function(){throw g},0);return[2]}I.label=1;case 1:if(I.trys.push([1,7,,8]),m=void 0,Q=void 0,u?("no-cache"!==l&&"network-only"!==l&&this.setQuery(e,function(){return{newData:null}}),m=u.result,Q=!u.complete||!1):y&&y.data&&!b?(m=y.data,Q=!1):(w=this.getQuery(e).document,S=this.dataStore.getCache().diff({query:w,variables:i.previousVariables||i.variables,optimistic:!0}),m=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:m,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,_=r.context,[4,this.localState.runResolvers({document:k,remoteResult:q,context:_,variables:R,onlyRunForcedResolvers:c})]):[3,4];case 3:E=I.sent(),q=t.__assign({},q,E),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]}})})}},e.prototype.watchQuery=function(e,o){void 0===o&&(o=!0),s.invariant("standby"!==e.fetchPolicy,9);var n=r.getQueryDefinition(e.query);if(n.variableDefinitions&&n.variableDefinitions.length){var i=r.getDefaultValues(n);e.variables=r.assign({},i,e.variables)}void 0===e.notifyOnNetworkStatusChange&&(e.notifyOnNetworkStatusChange=!1);var a=t.__assign({},e);return new y({queryManager:this,options:a,shouldSubscribe:o})},e.prototype.query=function(e){var t=this;return s.invariant(e.query,10),s.invariant("Document"===e.query.kind,11),s.invariant(!e.returnPartialData,12),s.invariant(!e.pollInterval,13),new Promise(function(r,o){var n=t.watchQuery(e,!1);t.fetchQueryRejectFns.set("query:"+n.queryId,o),n.result().then(r,o).then(function(){return t.fetchQueryRejectFns.delete("query:"+n.queryId)})})},e.prototype.generateQueryId=function(){return String(this.idCounter++)},e.prototype.stopQueryInStore=function(e){this.stopQueryInStoreNoBroadcast(e),this.broadcastQueries()},e.prototype.stopQueryInStoreNoBroadcast=function(e){this.stopPollingQuery(e),this.queryStore.stopQuery(e),this.invalidate(!0,e)},e.prototype.addQueryListener=function(e,t){this.setQuery(e,function(e){return e.listeners.add(t),{invalidated:!1}})},e.prototype.updateQueryWatch=function(e,t,r){var o=this,n=this.getQuery(e).cancel;n&&n();return this.dataStore.getCache().watch({query:t,variables:r.variables,optimistic:!0,previousResult:function(){var t=null,r=o.getQuery(e).observableQuery;if(r){var n=r.getLastResult();n&&(t=n.data)}return t},callback:function(t){o.setQuery(e,function(){return{invalidated:!0,newData:t}})}})},e.prototype.addObservableQuery=function(e,t){this.setQuery(e,function(){return{observableQuery:t}})},e.prototype.removeObservableQuery=function(e){var t=this.getQuery(e).cancel;this.setQuery(e,function(){return{observableQuery:null}}),t&&t()},e.prototype.clearStore=function(){this.fetchQueryRejectFns.forEach(function(e){e(new s.InvariantError(14))});var e=[];return this.queries.forEach(function(t,r){t.observableQuery&&e.push(r)}),this.queryStore.reset(e),this.mutationStore.reset(),this.dataStore.reset()},e.prototype.resetStore=function(){var e=this;return this.clearStore().then(function(){return e.reFetchObservableQueries()})},e.prototype.reFetchObservableQueries=function(e){var t=this;void 0===e&&(e=!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||!e&&"standby"===i||r.push(s.refetch()),t.setQuery(n,function(){return{newData:null}}),t.invalidate(!0,n)}}),this.broadcastQueries(),Promise.all(r)},e.prototype.startQuery=function(e,t,r){return this.addQueryListener(e,r),this.fetchQuery(e,t).catch(function(){}),e},e.prototype.startGraphQLSubscription=function(e){var o=this,n=e.query,s=e.fetchPolicy,i=e.variables,a=this.dataStore.getCache().transformDocument(n);i=t.__assign({},r.getDefaultValues(r.getOperationDefinition(a)),i);var c=function(e){return o.getObservableFromLink(a,{},e,!1).map(function(t){if(s&&"no-cache"===s||(o.dataStore.markSubscriptionResult(t,a,e),o.broadcastQueries()),r.graphQLResultHasError(t))throw new h({graphQLErrors:t.errors});return t})};if(r.hasClientExports(a)){var l=this.localState.addExportedVariables(a,i).then(c);return new u(function(e){var t=null;return l.then(function(r){return t=r.subscribe(e)},e.error),function(){return t&&t.unsubscribe()}})}return c(i)},e.prototype.stopQuery=function(e){this.stopQueryNoBroadcast(e),this.broadcastQueries()},e.prototype.stopQueryNoBroadcast=function(e){this.stopQueryInStoreNoBroadcast(e),this.removeQuery(e)},e.prototype.removeQuery=function(e){this.fetchQueryRejectFns.delete("query:"+e),this.fetchQueryRejectFns.delete("fetchRequest:"+e),this.getQuery(e).subscriptions.forEach(function(e){return e.unsubscribe()}),this.queries.delete(e)},e.prototype.getCurrentQueryResult=function(e,t){void 0===t&&(t=!0);var r=e.options,o=r.variables,n=r.query,s=r.fetchPolicy,i=e.getLastResult(),a=this.getQuery(e.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:t})||void 0,partial:!1}}catch(e){return{data:void 0,partial:!0}}},e.prototype.getQueryWithPreviousResult=function(e){var t;if("string"==typeof e){var r=this.getQuery(e).observableQuery;s.invariant(r,15),t=r}else t=e;var o=t.options,n=o.variables,i=o.query;return{previousResult:this.getCurrentQueryResult(t,!1).data,variables:n,document:i}},e.prototype.broadcastQueries=function(e){var t=this;void 0===e&&(e=!1),this.onBroadcast(),this.queries.forEach(function(r,o){r.invalidated&&r.listeners.forEach(function(n){n&&n(t.queryStore.get(o),r.newData,e)})})},e.prototype.getLocalState=function(){return this.localState},e.prototype.getObservableFromLink=function(e,r,n,s){var i,a=this;void 0===s&&(s=this.queryDeduplication);var c=this.localState.serverQuery(e);if(c){var l=this.inFlightLinkObservables,h=this.link,p=this.buildOperationForLink(c,n,t.__assign({},r,{forceFetch:!s}));if(r=p.context,s){var y=l.get(c)||new Map;l.set(c,y);var f=JSON.stringify(n);if(!(i=y.get(f))){y.set(f,i=Q(o.execute(h,p)));var d=function(){y.delete(f),y.size||l.delete(c),v.unsubscribe()},v=i.subscribe({next:d,error:d,complete:d})}}else i=Q(o.execute(h,p))}else i=u.of({data:{}}),r=this.prepareContext(r);var b=this.localState.clientQuery(e);return b&&(i=w(i,function(e){return a.localState.runResolvers({document:b,remoteResult:e,context:r,variables:n})})),i},e.prototype.fetchRequest=function(e){var t,r,o=this,n=e.requestId,s=e.queryId,i=e.document,a=e.options,u=e.fetchMoreForQueryId,c=a.variables,l=a.errorPolicy,p=void 0===l?"none":l,y=a.fetchPolicy;return new Promise(function(e,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(e){e.subscriptions.delete(b)})},b=f.map(function(e){if(n>=o.getQuery(s).lastRequestId&&("no-cache"!==y?o.dataStore.markQueryResult(e,i,c,u,"ignore"===p||"all"===p):o.setQuery(s,function(){return{newData:{result:e.data,complete:!0}}}),o.queryStore.markQueryResult(s,e,u),o.invalidate(!0,s,u),o.broadcastQueries()),e.errors&&"none"===p)throw new h({graphQLErrors:e.errors});if("all"===p&&(r=e.errors),u||"no-cache"===y)t=e.data;else try{t=o.dataStore.getCache().read({variables:c,query:i,optimistic:!1})}catch(e){}return t}).subscribe({error:function(e){v(),l(e)},complete:function(){v(),e({data:t,errors:r,loading:!1,networkStatus:exports.NetworkStatus.ready,stale:!1})}});o.setQuery(s,function(e){e.subscriptions.add(b)})})},e.prototype.getQuery=function(e){return this.queries.get(e)||{listeners:new Set,invalidated:!1,document:null,newData:null,lastRequestId:1,observableQuery:null,subscriptions:new Set}},e.prototype.setQuery=function(e,r){var o=this.getQuery(e),n=t.__assign({},o,r(o));this.queries.set(e,n)},e.prototype.invalidate=function(e,t,r){t&&this.setQuery(t,function(){return{invalidated:e}}),r&&this.setQuery(r,function(){return{invalidated:e}})},e.prototype.buildOperationForLink=function(e,t,o){return{query:this.dataStore.getCache().transformForLink(e),variables:t,operationName:r.getOperationName(e)||void 0,context:this.prepareContext(o)}},e.prototype.prepareContext=function(e){void 0===e&&(e={});var r=this.localState.prepareContext(e);return t.__assign({},r,{clientAwareness:this.clientAwareness})},e.prototype.checkInFlight=function(e){var t=this.queryStore.get(e);return t&&t.networkStatus!==exports.NetworkStatus.ready&&t.networkStatus!==exports.NetworkStatus.error},e.prototype.startPollingQuery=function(e,r,o){var n=e.pollInterval;return s.invariant(n,16),this.ssrMode||(this.pollingInfoByQueryId.set(r,{interval:n,lastPollTimeMs:Date.now()-10,options:t.__assign({},e,{fetchPolicy:"network-only"})}),o&&this.addQueryListener(r,o),this.schedulePoll(n)),r},e.prototype.stopPollingQuery=function(e){this.pollingInfoByQueryId.delete(e)},e.prototype.schedulePoll=function(e){var t=this,r=Date.now();if(this.nextPoll){if(!(e<this.nextPoll.time-r))return;clearTimeout(this.nextPoll.timeout)}this.nextPoll={time:r+e,timeout:setTimeout(function(){t.nextPoll=null;var e=1/0;t.pollingInfoByQueryId.forEach(function(r,o){if(r.interval<e&&(e=r.interval),!t.checkInFlight(o)&&Date.now()-r.lastPollTimeMs>=r.interval){var n=function(){r.lastPollTimeMs=Date.now()};t.fetchQuery(o,r.options,exports.FetchType.poll).then(n,n)}}),isFinite(e)&&t.schedulePoll(e)},e)}},e}(),k=function(){function e(e){this.cache=e}return e.prototype.getCache=function(){return this.cache},e.prototype.markQueryResult=function(e,t,o,n,s){void 0===s&&(s=!1);var i=!r.graphQLResultHasError(e);s&&r.graphQLResultHasError(e)&&e.data&&(i=!0),!n&&i&&this.cache.write({result:e.data,dataId:"ROOT_QUERY",query:t,variables:o})},e.prototype.markSubscriptionResult=function(e,t,o){r.graphQLResultHasError(e)||this.cache.write({result:e.data,dataId:"ROOT_SUBSCRIPTION",query:t,variables:o})},e.prototype.markMutationInit=function(e){var t=this;if(e.optimisticResponse){var r;r="function"==typeof e.optimisticResponse?e.optimisticResponse(e.variables):e.optimisticResponse;this.cache.recordOptimisticTransaction(function(o){var n=t.cache;t.cache=o;try{t.markMutationResult({mutationId:e.mutationId,result:{data:r},document:e.document,variables:e.variables,updateQueries:e.updateQueries,update:e.update})}finally{t.cache=n}},e.mutationId)}},e.prototype.markMutationResult=function(e){var t=this;if(!r.graphQLResultHasError(e.result)){var o=[];o.push({result:e.result.data,dataId:"ROOT_MUTATION",query:e.document,variables:e.variables}),e.updateQueries&&Object.keys(e.updateQueries).filter(function(t){return e.updateQueries[t]}).forEach(function(n){var s=e.updateQueries[n],i=s.query,a=s.updater,u=t.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:e.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(t){o.forEach(function(e){return t.write(e)});var n=e.update;n&&r.tryFunctionOrLogError(function(){return n(t,e.result)})})}},e.prototype.markMutationComplete=function(e){var t=e.mutationId;e.optimisticResponse&&this.cache.removeOptimistic(t)},e.prototype.markUpdateQueryResult=function(e,t,r){this.cache.write({result:r,dataId:"ROOT_QUERY",variables:t,query:e})},e.prototype.reset=function(){return this.cache.reset()},e}(),R="2.6.0-beta.0",_=!1,E=function(){function e(e){var t=this;this.defaultOptions={},this.resetStoreCallbacks=[],this.clearStoreCallbacks=[];var n=e.cache,i=e.ssrMode,a=void 0!==i&&i,u=e.ssrForceFetchDelay,c=void 0===u?0:u,l=e.connectToDevTools,h=e.queryDeduplication,p=void 0===h||h,y=e.defaultOptions,f=e.assumeImmutableResults,d=void 0!==f&&f,v=e.resolvers,b=e.typeDefs,g=e.fragmentMatcher,Q=e.name,w=e.version,S=e.link;if(!S&&v&&(S=o.ApolloLink.empty()),!S||!n)throw new s.InvariantError(1);var _=new Map,E=new o.ApolloLink(function(e,t){var o=_.get(e.query);return o||(o=r.removeConnectionDirectiveFromDocument(e.query),_.set(e.query,o),_.set(o,o)),e.query=o,t(e)});this.link=E.concat(S),this.cache=n,this.store=new k(n),this.disableNetworkFetches=a||c>0,this.queryDeduplication=p,this.defaultOptions=y||{},this.typeDefs=b,c&&setTimeout(function(){return t.disableNetworkFetches=!1},c),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!==l&&(l&&"undefined"!=typeof window)&&(window.__APOLLO_CLIENT__=this),this.version=R,this.localState=new m({cache:n,client:this,resolvers:v,fragmentMatcher:g}),this.queryManager=new q({link:this.link,store:this.store,queryDeduplication:p,ssrMode:a,clientAwareness:{name:Q,version:w},localState:this.localState,assumeImmutableResults:d,onBroadcast:function(){t.devToolsHookCb&&t.devToolsHookCb({action:{},state:{queries:t.queryManager.queryStore.getStore(),mutations:t.queryManager.mutationStore.getStore()},dataWithOptimisticResults:t.cache.extract(!0)})}})}return e.prototype.stop=function(){this.queryManager&&this.queryManager.stop()},e.prototype.watchQuery=function(e){return this.defaultOptions.watchQuery&&(e=t.__assign({},this.defaultOptions.watchQuery,e)),!this.disableNetworkFetches||"network-only"!==e.fetchPolicy&&"cache-and-network"!==e.fetchPolicy||(e=t.__assign({},e,{fetchPolicy:"cache-first"})),this.queryManager.watchQuery(e)},e.prototype.query=function(e){return this.defaultOptions.query&&(e=t.__assign({},this.defaultOptions.query,e)),s.invariant("cache-and-network"!==e.fetchPolicy,2),this.disableNetworkFetches&&"network-only"===e.fetchPolicy&&(e=t.__assign({},e,{fetchPolicy:"cache-first"})),this.queryManager.query(e)},e.prototype.mutate=function(e){return this.defaultOptions.mutate&&(e=t.__assign({},this.defaultOptions.mutate,e)),this.queryManager.mutate(e)},e.prototype.subscribe=function(e){return this.queryManager.startGraphQLSubscription(e)},e.prototype.readQuery=function(e,t){return void 0===t&&(t=!1),this.cache.readQuery(e,t)},e.prototype.readFragment=function(e,t){return void 0===t&&(t=!1),this.cache.readFragment(e,t)},e.prototype.writeQuery=function(e){var t=this.cache.writeQuery(e);return this.queryManager.broadcastQueries(),t},e.prototype.writeFragment=function(e){var t=this.cache.writeFragment(e);return this.queryManager.broadcastQueries(),t},e.prototype.writeData=function(e){var t=this.cache.writeData(e);return this.queryManager.broadcastQueries(),t},e.prototype.__actionHookForDevTools=function(e){this.devToolsHookCb=e},e.prototype.__requestRaw=function(e){return o.execute(this.link,e)},e.prototype.initQueryManager=function(){return this.queryManager},e.prototype.resetStore=function(){var e=this;return Promise.resolve().then(function(){return e.queryManager.clearStore()}).then(function(){return Promise.all(e.resetStoreCallbacks.map(function(e){return e()}))}).then(function(){return e.reFetchObservableQueries()})},e.prototype.clearStore=function(){var e=this;return Promise.resolve().then(function(){return Promise.all(e.clearStoreCallbacks.map(function(e){return e()}))}).then(function(){return e.queryManager.clearStore()})},e.prototype.onResetStore=function(e){var t=this;return this.resetStoreCallbacks.push(e),function(){t.resetStoreCallbacks=t.resetStoreCallbacks.filter(function(t){return t!==e})}},e.prototype.onClearStore=function(e){var t=this;return this.clearStoreCallbacks.push(e),function(){t.clearStoreCallbacks=t.clearStoreCallbacks.filter(function(t){return t!==e})}},e.prototype.reFetchObservableQueries=function(e){return this.queryManager.reFetchObservableQueries(e)},e.prototype.extract=function(e){return this.cache.extract(e)},e.prototype.restore=function(e){return this.cache.restore(e)},e.prototype.addResolvers=function(e){this.localState.addResolvers(e)},e.prototype.setResolvers=function(e){this.localState.setResolvers(e)},e.prototype.getResolvers=function(){return this.localState.getResolvers()},e.prototype.setLocalStateFragmentMatcher=function(e){this.localState.setFragmentMatcher(e)},e}();exports.default=E,exports.ApolloClient=E,exports.ObservableQuery=y,exports.isApolloError=c,exports.ApolloError=h; |
@@ -111,9 +111,7 @@ "use strict"; | ||
cacheWrites_1.forEach(function (write) { return c.write(write); }); | ||
var update = mutation.update; | ||
if (update) { | ||
apollo_utilities_1.tryFunctionOrLogError(function () { return update(c, mutation.result); }); | ||
} | ||
}); | ||
var update_1 = mutation.update; | ||
if (update_1) { | ||
this.cache.performTransaction(function (c) { | ||
apollo_utilities_1.tryFunctionOrLogError(function () { return update_1(c, mutation.result); }); | ||
}); | ||
} | ||
} | ||
@@ -120,0 +118,0 @@ }; |
{ | ||
"name": "apollo-client", | ||
"version": "2.5.1", | ||
"version": "2.6.0-beta.0", | ||
"description": "A simple yet functional GraphQL client.", | ||
@@ -27,8 +27,7 @@ "main": "bundle.umd.js", | ||
"@types/zen-observable": "^0.8.0", | ||
"apollo-cache": "1.2.1", | ||
"apollo-cache": "1.3.0-beta.0", | ||
"apollo-link": "^1.0.0", | ||
"apollo-link-dedup": "^1.0.0", | ||
"apollo-utilities": "1.2.1", | ||
"apollo-utilities": "1.3.0-beta.0", | ||
"symbol-observable": "^1.0.2", | ||
"ts-invariant": "^0.2.1", | ||
"ts-invariant": "^0.3.2", | ||
"tslib": "^1.9.3", | ||
@@ -35,0 +34,0 @@ "zen-observable": "^0.8.0" |
@@ -1,4 +0,4 @@ | ||
import { ObservableQuery } from '../../src/core/ObservableQuery'; | ||
import { ApolloQueryResult } from '../../src/core/types'; | ||
import { Subscription } from '../../src/util/Observable'; | ||
import { ObservableQuery } from '../core/ObservableQuery'; | ||
import { ApolloQueryResult } from '../core/types'; | ||
import { Subscription } from '../util/Observable'; | ||
export declare type Options = { | ||
@@ -5,0 +5,0 @@ observable: ObservableQuery<any>; |
/// <reference types="jest" /> | ||
import { ObservableQuery } from '../../src/core/ObservableQuery'; | ||
import { ApolloQueryResult } from '../../src/core/types'; | ||
import { Subscription } from '../../src/util/Observable'; | ||
import { ObservableQuery } from '../core/ObservableQuery'; | ||
import { ApolloQueryResult } from '../core/types'; | ||
import { Subscription } from '../util/Observable'; | ||
export default function subscribeAndCount(done: jest.DoneCallback, observable: ObservableQuery<any>, cb: (handleCount: number, result: ApolloQueryResult<any>) => any): Subscription; | ||
//# sourceMappingURL=subscribeAndCount.d.ts.map |
@@ -1,2 +0,2 @@ | ||
export declare const version = "2.5.1"; | ||
export declare const version = "2.6.0-beta.0"; | ||
//# sourceMappingURL=version.d.ts.map |
@@ -1,1 +0,1 @@ | ||
exports.version = "2.5.1" | ||
exports.version = "2.6.0-beta.0" |
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 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
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
9
1012220
66
7499
3
77
+ Addedapollo-cache@1.3.0-beta.0(transitive)
+ Addedapollo-utilities@1.3.0-beta.0(transitive)
+ Addedts-invariant@0.3.3(transitive)
- Removedapollo-link-dedup@^1.0.0
- Removedapollo-cache@1.2.1(transitive)
- Removedapollo-link-dedup@1.0.21(transitive)
- Removedapollo-utilities@1.2.1(transitive)
- Removedts-invariant@0.2.1(transitive)
Updatedapollo-cache@1.3.0-beta.0
Updatedts-invariant@^0.3.2