UNPKG

@wora/apollo-cache

Version:
27 lines 1.26 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); var apollo_cache_inmemory_1 = require("apollo-cache-inmemory"); var cache_persist_1 = require("@wora/cache-persist"); var ApolloCache = (function (_super) { tslib_1.__extends(ApolloCache, _super); function ApolloCache(options, persistOptions) { if (options === void 0) { options = {}; } if (persistOptions === void 0) { persistOptions = {}; } var _this = _super.call(this, options) || this; var persistOptionsApollo = tslib_1.__assign({ prefix: 'apollo-cache', serialize: true }, persistOptions); _this.cache = new cache_persist_1.Cache(persistOptionsApollo); _this.cache.toObject = function () { return _this.cache.getState(); }; _this.cache.clear = function () { return _this.cache.purge(); }; _this.data = _this.cache; _this.optimisticData = _this.cache; return _this; } ApolloCache.prototype.hydrate = function () { return this.cache.restore(); }; return ApolloCache; }(apollo_cache_inmemory_1.InMemoryCache)); exports.ApolloCache = ApolloCache; exports.default = ApolloCache; //# sourceMappingURL=index.js.map