This commit is contained in:
75
node_modules/apollo-cache/lib/cache.js
generated
vendored
Normal file
75
node_modules/apollo-cache/lib/cache.js
generated
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var apollo_utilities_1 = require("apollo-utilities");
|
||||
var utils_1 = require("./utils");
|
||||
var ApolloCache = (function () {
|
||||
function ApolloCache() {
|
||||
}
|
||||
ApolloCache.prototype.transformDocument = function (document) {
|
||||
return document;
|
||||
};
|
||||
ApolloCache.prototype.transformForLink = function (document) {
|
||||
return document;
|
||||
};
|
||||
ApolloCache.prototype.readQuery = function (options, optimistic) {
|
||||
if (optimistic === void 0) { optimistic = false; }
|
||||
return this.read({
|
||||
query: options.query,
|
||||
variables: options.variables,
|
||||
optimistic: optimistic,
|
||||
});
|
||||
};
|
||||
ApolloCache.prototype.readFragment = function (options, optimistic) {
|
||||
if (optimistic === void 0) { optimistic = false; }
|
||||
return this.read({
|
||||
query: apollo_utilities_1.getFragmentQueryDocument(options.fragment, options.fragmentName),
|
||||
variables: options.variables,
|
||||
rootId: options.id,
|
||||
optimistic: optimistic,
|
||||
});
|
||||
};
|
||||
ApolloCache.prototype.writeQuery = function (options) {
|
||||
this.write({
|
||||
dataId: 'ROOT_QUERY',
|
||||
result: options.data,
|
||||
query: options.query,
|
||||
variables: options.variables,
|
||||
});
|
||||
};
|
||||
ApolloCache.prototype.writeFragment = function (options) {
|
||||
this.write({
|
||||
dataId: options.id,
|
||||
result: options.data,
|
||||
variables: options.variables,
|
||||
query: apollo_utilities_1.getFragmentQueryDocument(options.fragment, options.fragmentName),
|
||||
});
|
||||
};
|
||||
ApolloCache.prototype.writeData = function (_a) {
|
||||
var id = _a.id, data = _a.data;
|
||||
if (typeof id !== 'undefined') {
|
||||
var typenameResult = null;
|
||||
try {
|
||||
typenameResult = this.read({
|
||||
rootId: id,
|
||||
optimistic: false,
|
||||
query: utils_1.justTypenameQuery,
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
}
|
||||
var __typename = (typenameResult && typenameResult.__typename) || '__ClientData';
|
||||
var dataToWrite = Object.assign({ __typename: __typename }, data);
|
||||
this.writeFragment({
|
||||
id: id,
|
||||
fragment: utils_1.fragmentFromPojo(dataToWrite, __typename),
|
||||
data: dataToWrite,
|
||||
});
|
||||
}
|
||||
else {
|
||||
this.writeQuery({ query: utils_1.queryFromPojo(data), data: data });
|
||||
}
|
||||
};
|
||||
return ApolloCache;
|
||||
}());
|
||||
exports.ApolloCache = ApolloCache;
|
||||
//# sourceMappingURL=cache.js.map
|
||||
Reference in New Issue
Block a user