Socket
Socket
Sign inDemoInstall

apollo-cache-inmemory

Package Overview
Dependencies
Maintainers
4
Versions
149
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

apollo-cache-inmemory - npm Package Compare versions

Comparing version 1.4.0-alpha.1 to 1.4.0-alpha.2

lib/fixPolyfills.d.ts

413

lib/bundle.umd.js
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('apollo-utilities'), require('graphql/language/printer'), require('apollo-cache')) :
typeof define === 'function' && define.amd ? define(['exports', 'apollo-utilities', 'graphql/language/printer', 'apollo-cache'], factory) :
(factory((global.apollo = global.apollo || {}, global.apollo.cache = global.apollo.cache || {}, global.apollo.cache.inmemory = {}),global.apollo.utilities,global.print,global.apolloCache.core));
}(this, (function (exports,apolloUtilities,printer,apolloCache) { 'use strict';
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('apollo-cache'), require('graphql/language/visitor'), require('graphql/language/printer'), require('apollo-utilities')) :
typeof define === 'function' && define.amd ? define(['exports', 'apollo-cache', 'graphql/language/visitor', 'graphql/language/printer', 'apollo-utilities'], factory) :
(factory((global.apollo = global.apollo || {}, global.apollo.cache = global.apollo.cache || {}, global.apollo.cache.inmemory = {}),global.apolloCache.core,global.visitor,global.print,global.apollo.utilities));
}(this, (function (exports,apolloCache,visitor,printer,apolloUtilities) { 'use strict';
var testMap = new Map();
if (testMap.set(1, 2) !== testMap) {
var set_1 = testMap.set;
Map.prototype.set = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
set_1.apply(this, args);
return this;
};
}
var testSet = new Set();
if (testSet.add(3) !== testSet) {
var add_1 = testSet.add;
Set.prototype.add = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
add_1.apply(this, args);
return this;
};
}
var frozen = {};
if (typeof Object.freeze === 'function') {
Object.freeze(frozen);
}
try {
testMap.set(frozen, frozen).delete(frozen);
}
catch (_a) {
var wrap = function (method) {
return (method &&
(function (obj) {
try {
testMap.set(obj, obj).delete(obj);
}
finally {
return method.call(Object, obj);
}
}));
};
Object.freeze = wrap(Object.freeze);
Object.seal = wrap(Object.seal);
Object.preventExtensions = wrap(Object.preventExtensions);
}
var haveWarned = false;

@@ -92,3 +140,3 @@ var HeuristicFragmentMatcher = (function () {

var wrap = require('optimism').wrap;
var wrap$1 = require('optimism').wrap;
var CacheKeyNode = (function () {

@@ -114,4 +162,8 @@ function CacheKeyNode() {

CacheKeyNode.prototype.getOrCreate = function (value) {
var map = this.children || (this.children = new Map);
return map.get(value) || map.set(value, new CacheKeyNode()).get(value);
var map = this.children || (this.children = new Map());
var node = map.get(value);
if (!node) {
map.set(value, (node = new CacheKeyNode()));
}
return node;
};

@@ -127,3 +179,3 @@ return CacheKeyNode;

this.data = data;
this.depend = wrap(function (dataId) { return _this.data[dataId]; }, {
this.depend = wrap$1(function (dataId) { return _this.data[dataId]; }, {
disposable: true,

@@ -194,2 +246,3 @@ makeCacheKey: function (dataId) {

var CIRCULAR = Object.create(null);
var objToStr = Object.prototype.toString;
var QueryKeyMaker = (function () {

@@ -212,3 +265,3 @@ function QueryKeyMaker(cacheKeyRoot) {

this.query = query;
this.cache = new Map;
this.cache = new Map();
this.lookupArray = this.cacheMethod(this.lookupArray);

@@ -224,3 +277,3 @@ this.lookupObject = this.cacheMethod(this.lookupObject);

if (cached === CIRCULAR) {
throw new Error("QueryKeyMaker cannot handle circular query structures");
throw new Error('QueryKeyMaker cannot handle circular query structures');
}

@@ -251,3 +304,3 @@ return cached;

this.query.definitions.some(function (definition) {
if (definition.kind === "FragmentDefinition" &&
if (definition.kind === 'FragmentDefinition' &&
definition.name.value === name) {

@@ -257,2 +310,3 @@ fragment = definition;

}
return false;
});

@@ -265,4 +319,4 @@ return this.lookupObject(__assign({}, fragmentSpread, { fragment: fragment }));

}
if (typeof value === "object" && value !== null) {
if (value.kind === "FragmentSpread") {
if (typeof value === 'object' && value !== null) {
if (value.kind === 'FragmentSpread') {
return this.lookupFragmentSpread(value);

@@ -276,16 +330,38 @@ }

var elements = array.map(this.lookupAny, this);
return this.cacheKeyRoot.lookup(Array.prototype, this.cacheKeyRoot.lookupArray(elements));
return this.cacheKeyRoot.lookup(objToStr.call(array), this.cacheKeyRoot.lookupArray(elements));
};
PerQueryKeyMaker.prototype.lookupObject = function (object) {
var _this = this;
var keys = Object.keys(object);
var locIndex = keys.indexOf("loc");
if (locIndex >= 0)
keys.splice(locIndex, 1);
keys.sort();
var keys = safeSortedKeys(object);
var values = keys.map(function (key) { return _this.lookupAny(object[key]); });
return this.cacheKeyRoot.lookup(Object.getPrototypeOf(object), this.cacheKeyRoot.lookupArray(keys), this.cacheKeyRoot.lookupArray(values));
return this.cacheKeyRoot.lookup(objToStr.call(object), this.cacheKeyRoot.lookupArray(keys), this.cacheKeyRoot.lookupArray(values));
};
return PerQueryKeyMaker;
}());
var queryKeyMap = Object.create(null);
Object.keys(visitor.QueryDocumentKeys).forEach(function (parentKind) {
var childKeys = (queryKeyMap[parentKind] = Object.create(null));
visitor.QueryDocumentKeys[parentKind].forEach(function (childKey) {
childKeys[childKey] = true;
});
if (parentKind === 'FragmentSpread') {
childKeys['fragment'] = true;
}
});
function safeSortedKeys(object) {
var keys = Object.keys(object);
var keyCount = keys.length;
var knownKeys = typeof object.kind === 'string' && queryKeyMap[object.kind];
var target = 0;
for (var source = target; source < keyCount; ++source) {
var key = keys[source];
var value = object[key];
var isObjectOrArray = value !== null && typeof value === 'object';
if (!isObjectOrArray || !knownKeys || knownKeys[key] === true) {
keys[target++] = key;
}
}
keys.length = target;
return keys.sort();
}

@@ -304,21 +380,22 @@ var __assign$1 = (undefined && undefined.__assign) || function () {

var StoreReader = (function () {
function StoreReader(_a) {
var _b = _a === void 0 ? {} : _a, _c = _b.addTypename, addTypename = _c === void 0 ? false : _c, _d = _b.cacheKeyRoot, cacheKeyRoot = _d === void 0 ? new CacheKeyNode : _d;
function StoreReader(cacheKeyRoot) {
if (cacheKeyRoot === void 0) { cacheKeyRoot = new CacheKeyNode(); }
var _this = this;
this.cacheKeyRoot = cacheKeyRoot;
var reader = this;
var executeStoreQuery = reader.executeStoreQuery, executeSelectionSet = reader.executeSelectionSet;
reader.addTypename = addTypename;
reader.cacheKeyRoot = cacheKeyRoot;
reader.keyMaker = new QueryKeyMaker(cacheKeyRoot);
this.executeStoreQuery = wrap(function (options) {
return executeStoreQuery.call(reader, options);
this.executeStoreQuery = wrap$1(function (options) {
return executeStoreQuery.call(_this, options);
}, {
makeCacheKey: function (_a) {
var query = _a.query, rootValue = _a.rootValue, contextValue = _a.contextValue, variableValues = _a.variableValues;
var query = _a.query, rootValue = _a.rootValue, contextValue = _a.contextValue, variableValues = _a.variableValues, fragmentMatcher = _a.fragmentMatcher;
if (contextValue.store instanceof DepTrackingCache) {
return reader.cacheKeyRoot.lookup(reader.keyMaker.forQuery(query).lookupQuery(query), contextValue.store, JSON.stringify(variableValues));
return reader.cacheKeyRoot.lookup(reader.keyMaker.forQuery(query).lookupQuery(query), contextValue.store, fragmentMatcher, JSON.stringify(variableValues), rootValue.id);
}
}
return;
},
});
this.executeSelectionSet = wrap(function (options) {
return executeSelectionSet.call(reader, options);
this.executeSelectionSet = wrap$1(function (options) {
return executeSelectionSet.call(_this, options);
}, {

@@ -328,5 +405,8 @@ makeCacheKey: function (_a) {

if (execContext.contextValue.store instanceof DepTrackingCache) {
return reader.cacheKeyRoot.lookup(reader.keyMaker.forQuery(execContext.query).lookupSelectionSet(selectionSet), execContext.contextValue.store, JSON.stringify(execContext.variableValues), rootValue.id);
return reader.cacheKeyRoot.lookup(reader.keyMaker
.forQuery(execContext.query)
.lookupSelectionSet(selectionSet), execContext.contextValue.store, execContext.fragmentMatcher, JSON.stringify(execContext.variableValues), rootValue.id);
}
}
return;
},
});

@@ -364,3 +444,3 @@ }

return;
throw new Error("Can't find field " + info.fieldName + " on object (" + info.objectId + ") " + JSON.stringify(store.get(info.objectId), null, 2) + ".");
throw new Error("Can't find field " + info.fieldName + " on object " + JSON.stringify(info.object, null, 2) + ".");
});

@@ -379,3 +459,3 @@ }

StoreReader.prototype.executeStoreQuery = function (_a) {
var query = _a.query, rootValue = _a.rootValue, contextValue = _a.contextValue, variableValues = _a.variableValues, _b = _a.fragmentMatcher, fragmentMatcher = _b === void 0 ? function () { return true; } : _b;
var query = _a.query, rootValue = _a.rootValue, contextValue = _a.contextValue, variableValues = _a.variableValues, _b = _a.fragmentMatcher, fragmentMatcher = _b === void 0 ? defaultFragmentMatcher : _b;
var mainDefinition = apolloUtilities.getMainDefinition(query);

@@ -395,3 +475,2 @@ var fragments = apolloUtilities.getFragmentDefinitions(query);

execContext: execContext,
parentKind: mainDefinition.kind,
});

@@ -401,3 +480,3 @@ };

var _this = this;
var selectionSet = _a.selectionSet, rootValue = _a.rootValue, execContext = _a.execContext, parentKind = _a.parentKind;
var selectionSet = _a.selectionSet, rootValue = _a.rootValue, execContext = _a.execContext;
var fragmentMap = execContext.fragmentMap, contextValue = execContext.contextValue, variables = execContext.variableValues;

@@ -407,3 +486,7 @@ var finalResult = {

};
var didReadTypename = false;
var objectsToMerge = [];
var object = contextValue.store.get(rootValue.id);
var typename = (object && object.__typename) ||
(rootValue.id === 'ROOT_QUERY' && 'Query') ||
void 0;
function handleMissing(result) {

@@ -417,3 +500,3 @@ var _a;

}
var handleSelection = function (selection) {
selectionSet.selections.forEach(function (selection) {
var _a;

@@ -424,10 +507,6 @@ if (!apolloUtilities.shouldInclude(selection, variables)) {

if (apolloUtilities.isField(selection)) {
var fieldResult = handleMissing(_this.executeField(selection, rootValue, execContext));
var keyName = apolloUtilities.resultKeyNameFromField(selection);
if (keyName === "__typename") {
didReadTypename = true;
}
var fieldResult = handleMissing(_this.executeField(object, typename, selection, execContext));
if (typeof fieldResult !== 'undefined') {
merge(finalResult.result, (_a = {},
_a[keyName] = fieldResult,
objectsToMerge.push((_a = {},
_a[apolloUtilities.resultKeyNameFromField(selection)] = fieldResult,
_a));

@@ -454,3 +533,2 @@ }

execContext: execContext,
parentKind: fragment.kind,
});

@@ -462,21 +540,10 @@ if (match === 'heuristic' && fragmentExecResult.missing) {

}
merge(finalResult.result, handleMissing(fragmentExecResult));
objectsToMerge.push(handleMissing(fragmentExecResult));
}
}
};
selectionSet.selections.forEach(handleSelection);
if (!didReadTypename &&
this.addTypename &&
parentKind !== "OperationDefinition") {
handleSelection({
kind: "Field",
name: {
kind: "Name",
value: "__typename",
},
});
}
});
merge(finalResult.result, objectsToMerge);
return finalResult;
};
StoreReader.prototype.executeField = function (field, rootValue, execContext) {
StoreReader.prototype.executeField = function (object, typename, field, execContext) {
var variables = execContext.variableValues, contextValue = execContext.contextValue;

@@ -489,4 +556,8 @@ var fieldName = field.name.value;

};
var readStoreResult = readStoreResolver(fieldName, rootValue, args, contextValue, info);
var readStoreResult = readStoreResolver(object, typename, fieldName, args, contextValue, info);
if (Array.isArray(readStoreResult.result)) {
return this.combineExecResults(readStoreResult, this.executeSubSelectedArray(field, readStoreResult.result, execContext));
}
if (!field.selectionSet) {
assertSelectionSetForIdValue(field, readStoreResult.result);
return readStoreResult;

@@ -497,27 +568,25 @@ }

}
function handleMissing(res) {
var missing = null;
if (readStoreResult.missing) {
missing = missing || [];
missing.push.apply(missing, readStoreResult.missing);
}
if (res.missing) {
missing = missing || [];
missing.push.apply(missing, res.missing);
}
return {
result: res.result,
missing: missing,
};
}
if (Array.isArray(readStoreResult.result)) {
return handleMissing(this.executeSubSelectedArray(field, readStoreResult.result, execContext));
}
return handleMissing(this.executeSelectionSet({
return this.combineExecResults(readStoreResult, this.executeSelectionSet({
selectionSet: field.selectionSet,
rootValue: readStoreResult.result,
execContext: execContext,
parentKind: field.kind,
}));
};
StoreReader.prototype.combineExecResults = function () {
var execResults = [];
for (var _i = 0; _i < arguments.length; _i++) {
execResults[_i] = arguments[_i];
}
var missing = null;
execResults.forEach(function (execResult) {
if (execResult.missing) {
missing = missing || [];
missing.push.apply(missing, execResult.missing);
}
});
return {
result: execResults.pop().result,
missing: missing,
};
};
StoreReader.prototype.executeSubSelectedArray = function (field, result, execContext) {

@@ -540,8 +609,11 @@ var _this = this;

}
return handleMissing(_this.executeSelectionSet({
selectionSet: field.selectionSet,
rootValue: item,
execContext: execContext,
parentKind: field.kind,
}));
if (field.selectionSet) {
return handleMissing(_this.executeSelectionSet({
selectionSet: field.selectionSet,
rootValue: item,
execContext: execContext,
}));
}
assertSelectionSetForIdValue(field, item);
return item;
});

@@ -552,2 +624,10 @@ return { result: result, missing: missing };

}());
function assertSelectionSetForIdValue(field, value) {
if (!field.selectionSet && apolloUtilities.isIdValue(value)) {
throw new Error("Missing selection set for object of type " + value.typename + " returned for query field " + field.name.value);
}
}
function defaultFragmentMatcher() {
return true;
}
function assertIdValue(idValue) {

@@ -558,7 +638,4 @@ if (!apolloUtilities.isIdValue(idValue)) {

}
function readStoreResolver(fieldName, idValue, args, context, _a) {
function readStoreResolver(object, typename, fieldName, args, context, _a) {
var resultKey = _a.resultKey, directives = _a.directives;
assertIdValue(idValue);
var objId = idValue.id;
var obj = context.store.get(objId);
var storeKeyName = fieldName;

@@ -569,8 +646,7 @@ if (args || directives) {

var fieldValue = void 0;
if (obj) {
fieldValue = obj[storeKeyName];
if (object) {
fieldValue = object[storeKeyName];
if (typeof fieldValue === 'undefined' &&
context.cacheRedirects &&
(obj.__typename || objId === 'ROOT_QUERY')) {
var typename = obj.__typename || 'Query';
typeof typename === 'string') {
var type = context.cacheRedirects[typename];

@@ -580,3 +656,3 @@ if (type) {

if (resolver) {
fieldValue = resolver(obj, args, {
fieldValue = resolver(object, args, {
getCacheKey: function (storeObj) {

@@ -596,7 +672,9 @@ return apolloUtilities.toIdValue({

result: fieldValue,
missing: [{
objectId: objId,
missing: [
{
object: object,
fieldName: storeKeyName,
tolerable: false,
}],
},
],
};

@@ -612,15 +690,24 @@ }

var hasOwn$1 = Object.prototype.hasOwnProperty;
function merge(target, source) {
if (source !== null && typeof source === 'object' &&
source !== target) {
function merge(target, sources) {
var pastCopies = [];
sources.forEach(function (source) {
mergeHelper(target, source, pastCopies);
});
return target;
}
function mergeHelper(target, source, pastCopies) {
if (source !== null && typeof source === 'object') {
if (Object.isExtensible && !Object.isExtensible(target)) {
target = __assign$1({}, target);
target = shallowCopyForMerge(target, pastCopies);
}
Object.keys(source).forEach(function (sourceKey) {
var sourceVal = source[sourceKey];
if (!hasOwn$1.call(target, sourceKey)) {
target[sourceKey] = sourceVal;
var sourceValue = source[sourceKey];
if (hasOwn$1.call(target, sourceKey)) {
var targetValue = target[sourceKey];
if (sourceValue !== targetValue) {
target[sourceKey] = mergeHelper(shallowCopyForMerge(targetValue, pastCopies), sourceValue, pastCopies);
}
}
else {
target[sourceKey] = merge(target[sourceKey], sourceVal);
target[sourceKey] = sourceValue;
}

@@ -631,2 +718,16 @@ });

}
function shallowCopyForMerge(value, pastCopies) {
if (value !== null &&
typeof value === 'object' &&
pastCopies.indexOf(value) < 0) {
if (Array.isArray(value)) {
value = value.slice(0);
}
else {
value = __assign$1({}, value);
}
pastCopies.push(value);
}
return value;
}

@@ -701,13 +802,4 @@ var ObjectCache = (function () {

}
var TYPENAME_FIELD = {
kind: 'Field',
name: {
kind: 'Name',
value: '__typename',
},
};
var StoreWriter = (function () {
function StoreWriter(_a) {
var _b = (_a === void 0 ? {} : _a).addTypename, addTypename = _b === void 0 ? false : _b;
this.addTypename = addTypename;
function StoreWriter() {
}

@@ -742,3 +834,2 @@ StoreWriter.prototype.writeQueryToStore = function (_a) {

},
parentKind: operationDefinition.kind,
});

@@ -752,5 +843,4 @@ }

var _this = this;
var result = _a.result, dataId = _a.dataId, selectionSet = _a.selectionSet, context = _a.context, parentKind = _a.parentKind;
var result = _a.result, dataId = _a.dataId, selectionSet = _a.selectionSet, context = _a.context;
var variables = context.variables, store = context.store, fragmentMap = context.fragmentMap;
var didWriteTypename = false;
selectionSet.selections.forEach(function (selection) {

@@ -763,5 +853,2 @@ if (!apolloUtilities.shouldInclude(selection, variables)) {

var value = result[resultFieldKey];
if (resultFieldKey === "__typename") {
didWriteTypename = true;
}
if (typeof value !== 'undefined') {

@@ -776,6 +863,9 @@ _this.writeFieldToStore({

else {
var isDefered = selection.directives &&
selection.directives.length &&
selection.directives.some(function (directive) { return directive.name && directive.name.value === 'defer'; });
if (!isDefered && context.fragmentMatcherFunction) {
var isDefered = false;
var isClient = false;
if (selection.directives && selection.directives.length) {
isDefered = selection.directives.some(function (directive) { return directive.name && directive.name.value === 'defer'; });
isClient = selection.directives.some(function (directive) { return directive.name && directive.name.value === 'client'; });
}
if (!isDefered && !isClient && context.fragmentMatcherFunction) {
if (!apolloUtilities.isProduction()) {

@@ -817,3 +907,2 @@ console.warn("Missing field " + resultFieldKey + " in " + JSON.stringify(result, null, 2).substring(0, 100));

context: context,
parentKind: fragment.kind,
});

@@ -823,13 +912,2 @@ }

});
if (!didWriteTypename &&
this.addTypename &&
parentKind !== "OperationDefinition" &&
typeof result.__typename === "string") {
this.writeFieldToStore({
dataId: dataId,
value: result.__typename,
field: TYPENAME_FIELD,
context: context,
});
}
return store;

@@ -854,3 +932,3 @@ };

var generatedId = dataId + "." + storeFieldName;
storeValue = this.processArrayValue(value, generatedId, field.selectionSet, context, field.kind);
storeValue = this.processArrayValue(value, generatedId, field.selectionSet, context);
}

@@ -880,3 +958,2 @@ else {

context: context,
parentKind: field.kind,
});

@@ -921,3 +998,3 @@ }

};
StoreWriter.prototype.processArrayValue = function (value, generatedId, selectionSet, context, parentKind) {
StoreWriter.prototype.processArrayValue = function (value, generatedId, selectionSet, context) {
var _this = this;

@@ -930,3 +1007,3 @@ return value.map(function (item, index) {

if (Array.isArray(item)) {
return _this.processArrayValue(item, itemDataId, selectionSet, context, parentKind);
return _this.processArrayValue(item, itemDataId, selectionSet, context);
}

@@ -947,3 +1024,2 @@ var generated = true;

context: context,
parentKind: parentKind,
});

@@ -1120,12 +1196,7 @@ }

_this.data = defaultNormalizedCacheFactory();
_this.storeReader = new StoreReader({
addTypename: _this.config.addTypename,
cacheKeyRoot: _this.cacheKeyRoot,
});
_this.storeWriter = new StoreWriter({
addTypename: _this.config.addTypename,
});
_this.storeReader = new StoreReader(_this.cacheKeyRoot);
_this.storeWriter = new StoreWriter();
var cache = _this;
var maybeBroadcastWatch = cache.maybeBroadcastWatch;
_this.maybeBroadcastWatch = wrap(function (c) {
_this.maybeBroadcastWatch = wrap$1(function (c) {
return maybeBroadcastWatch.call(_this, c);

@@ -1143,3 +1214,3 @@ }, {

}
}
},
});

@@ -1165,3 +1236,3 @@ return _this;

}
var store = (query.optimistic && this.optimistic.length)
var store = query.optimistic && this.optimistic.length
? defaultNormalizedCacheFactory(this.extract(true))

@@ -1171,3 +1242,3 @@ : this.data;

store: store,
query: query.query,
query: this.transformDocument(query.query),
variables: query.variables,

@@ -1185,3 +1256,3 @@ rootId: query.rootId,

variables: write.variables,
document: write.query,
document: this.transformDocument(write.query),
store: this.data,

@@ -1194,3 +1265,3 @@ dataIdFromObject: this.config.dataIdFromObject,

InMemoryCache.prototype.diff = function (query) {
var store = (query.optimistic && this.optimistic.length)
var store = query.optimistic && this.optimistic.length
? defaultNormalizedCacheFactory(this.extract(true))

@@ -1200,3 +1271,3 @@ : this.data;

store: store,
query: query.query,
query: this.transformDocument(query.query),
variables: query.variables,

@@ -1263,3 +1334,5 @@ returnPartialData: query.returnPartialData,

if (!result) {
this.typenameDocumentCache.set(document, (result = apolloUtilities.addTypenameToDocument(document)));
result = apolloUtilities.addTypenameToDocument(document);
this.typenameDocumentCache.set(document, result);
this.typenameDocumentCache.set(result, result);
}

@@ -1281,3 +1354,3 @@ return result;

return this.read({
query: apolloUtilities.getFragmentQueryDocument(options.fragment, options.fragmentName),
query: this.transformDocument(apolloUtilities.getFragmentQueryDocument(options.fragment, options.fragmentName)),
variables: options.variables,

@@ -1292,3 +1365,3 @@ rootId: options.id,

result: options.data,
query: options.query,
query: this.transformDocument(options.query),
variables: options.variables,

@@ -1301,3 +1374,3 @@ });

result: options.data,
query: apolloUtilities.getFragmentQueryDocument(options.fragment, options.fragmentName),
query: this.transformDocument(apolloUtilities.getFragmentQueryDocument(options.fragment, options.fragmentName)),
variables: options.variables,

@@ -1319,14 +1392,8 @@ });

InMemoryCache.prototype.maybeBroadcastWatch = function (c) {
var previousResult = c.previousResult && c.previousResult();
var newData = this.diff({
c.callback(this.diff({
query: c.query,
variables: c.variables,
previousResult: previousResult,
previousResult: c.previousResult && c.previousResult(),
optimistic: c.optimistic,
});
if (previousResult &&
previousResult === newData.result) {
return;
}
c.callback(newData);
}));
};

@@ -1333,0 +1400,0 @@ return InMemoryCache;

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

import './fixPolyfills';
import { DocumentNode } from 'graphql';

@@ -2,0 +3,0 @@ import { Cache, DataProxy, ApolloCache, Transaction } from 'apollo-cache';

@@ -25,2 +25,3 @@ var __extends = (this && this.__extends) || (function () {

};
import './fixPolyfills';
import { ApolloCache } from 'apollo-cache';

@@ -31,3 +32,3 @@ import { getFragmentQueryDocument, addTypenameToDocument, } from 'apollo-utilities';

import { StoreWriter } from './writeToStore';
import { defaultNormalizedCacheFactory, DepTrackingCache } from './depTrackingCache';
import { defaultNormalizedCacheFactory, DepTrackingCache, } from './depTrackingCache';
import { wrap, CacheKeyNode } from './optimism';

@@ -72,9 +73,4 @@ import { record } from './recordingCache';

_this.data = defaultNormalizedCacheFactory();
_this.storeReader = new StoreReader({
addTypename: _this.config.addTypename,
cacheKeyRoot: _this.cacheKeyRoot,
});
_this.storeWriter = new StoreWriter({
addTypename: _this.config.addTypename,
});
_this.storeReader = new StoreReader(_this.cacheKeyRoot);
_this.storeWriter = new StoreWriter();
var cache = _this;

@@ -95,3 +91,3 @@ var maybeBroadcastWatch = cache.maybeBroadcastWatch;

}
}
},
});

@@ -117,3 +113,3 @@ return _this;

}
var store = (query.optimistic && this.optimistic.length)
var store = query.optimistic && this.optimistic.length
? defaultNormalizedCacheFactory(this.extract(true))

@@ -123,3 +119,3 @@ : this.data;

store: store,
query: query.query,
query: this.transformDocument(query.query),
variables: query.variables,

@@ -137,3 +133,3 @@ rootId: query.rootId,

variables: write.variables,
document: write.query,
document: this.transformDocument(write.query),
store: this.data,

@@ -146,3 +142,3 @@ dataIdFromObject: this.config.dataIdFromObject,

InMemoryCache.prototype.diff = function (query) {
var store = (query.optimistic && this.optimistic.length)
var store = query.optimistic && this.optimistic.length
? defaultNormalizedCacheFactory(this.extract(true))

@@ -152,3 +148,3 @@ : this.data;

store: store,
query: query.query,
query: this.transformDocument(query.query),
variables: query.variables,

@@ -215,3 +211,5 @@ returnPartialData: query.returnPartialData,

if (!result) {
this.typenameDocumentCache.set(document, (result = addTypenameToDocument(document)));
result = addTypenameToDocument(document);
this.typenameDocumentCache.set(document, result);
this.typenameDocumentCache.set(result, result);
}

@@ -233,3 +231,3 @@ return result;

return this.read({
query: getFragmentQueryDocument(options.fragment, options.fragmentName),
query: this.transformDocument(getFragmentQueryDocument(options.fragment, options.fragmentName)),
variables: options.variables,

@@ -244,3 +242,3 @@ rootId: options.id,

result: options.data,
query: options.query,
query: this.transformDocument(options.query),
variables: options.variables,

@@ -253,3 +251,3 @@ });

result: options.data,
query: getFragmentQueryDocument(options.fragment, options.fragmentName),
query: this.transformDocument(getFragmentQueryDocument(options.fragment, options.fragmentName)),
variables: options.variables,

@@ -271,14 +269,8 @@ });

InMemoryCache.prototype.maybeBroadcastWatch = function (c) {
var previousResult = c.previousResult && c.previousResult();
var newData = this.diff({
c.callback(this.diff({
query: c.query,
variables: c.variables,
previousResult: previousResult,
previousResult: c.previousResult && c.previousResult(),
optimistic: c.optimistic,
});
if (previousResult &&
previousResult === newData.result) {
return;
}
c.callback(newData);
}));
};

@@ -285,0 +277,0 @@ return InMemoryCache;

@@ -23,4 +23,8 @@ var wrap = require('optimism').wrap;

CacheKeyNode.prototype.getOrCreate = function (value) {
var map = this.children || (this.children = new Map);
return map.get(value) || map.set(value, new CacheKeyNode()).get(value);
var map = this.children || (this.children = new Map());
var node = map.get(value);
if (!node) {
map.set(value, (node = new CacheKeyNode()));
}
return node;
};

@@ -27,0 +31,0 @@ return CacheKeyNode;

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

import { CacheKeyNode } from "./optimism";
import { DocumentNode, SelectionSetNode } from "graphql";
import { CacheKeyNode } from './optimism';
import { DocumentNode, SelectionSetNode } from 'graphql';
export declare class QueryKeyMaker {

@@ -4,0 +4,0 @@ private cacheKeyRoot;

@@ -12,3 +12,5 @@ var __assign = (this && this.__assign) || function () {

};
import { QueryDocumentKeys } from 'graphql/language/visitor';
var CIRCULAR = Object.create(null);
var objToStr = Object.prototype.toString;
var QueryKeyMaker = (function () {

@@ -32,3 +34,3 @@ function QueryKeyMaker(cacheKeyRoot) {

this.query = query;
this.cache = new Map;
this.cache = new Map();
this.lookupArray = this.cacheMethod(this.lookupArray);

@@ -44,3 +46,3 @@ this.lookupObject = this.cacheMethod(this.lookupObject);

if (cached === CIRCULAR) {
throw new Error("QueryKeyMaker cannot handle circular query structures");
throw new Error('QueryKeyMaker cannot handle circular query structures');
}

@@ -71,3 +73,3 @@ return cached;

this.query.definitions.some(function (definition) {
if (definition.kind === "FragmentDefinition" &&
if (definition.kind === 'FragmentDefinition' &&
definition.name.value === name) {

@@ -77,2 +79,3 @@ fragment = definition;

}
return false;
});

@@ -85,4 +88,4 @@ return this.lookupObject(__assign({}, fragmentSpread, { fragment: fragment }));

}
if (typeof value === "object" && value !== null) {
if (value.kind === "FragmentSpread") {
if (typeof value === 'object' && value !== null) {
if (value.kind === 'FragmentSpread') {
return this.lookupFragmentSpread(value);

@@ -96,16 +99,38 @@ }

var elements = array.map(this.lookupAny, this);
return this.cacheKeyRoot.lookup(Array.prototype, this.cacheKeyRoot.lookupArray(elements));
return this.cacheKeyRoot.lookup(objToStr.call(array), this.cacheKeyRoot.lookupArray(elements));
};
PerQueryKeyMaker.prototype.lookupObject = function (object) {
var _this = this;
var keys = Object.keys(object);
var locIndex = keys.indexOf("loc");
if (locIndex >= 0)
keys.splice(locIndex, 1);
keys.sort();
var keys = safeSortedKeys(object);
var values = keys.map(function (key) { return _this.lookupAny(object[key]); });
return this.cacheKeyRoot.lookup(Object.getPrototypeOf(object), this.cacheKeyRoot.lookupArray(keys), this.cacheKeyRoot.lookupArray(values));
return this.cacheKeyRoot.lookup(objToStr.call(object), this.cacheKeyRoot.lookupArray(keys), this.cacheKeyRoot.lookupArray(values));
};
return PerQueryKeyMaker;
}());
var queryKeyMap = Object.create(null);
Object.keys(QueryDocumentKeys).forEach(function (parentKind) {
var childKeys = (queryKeyMap[parentKind] = Object.create(null));
QueryDocumentKeys[parentKind].forEach(function (childKey) {
childKeys[childKey] = true;
});
if (parentKind === 'FragmentSpread') {
childKeys['fragment'] = true;
}
});
function safeSortedKeys(object) {
var keys = Object.keys(object);
var keyCount = keys.length;
var knownKeys = typeof object.kind === 'string' && queryKeyMap[object.kind];
var target = 0;
for (var source = target; source < keyCount; ++source) {
var key = keys[source];
var value = object[key];
var isObjectOrArray = value !== null && typeof value === 'object';
if (!isObjectOrArray || !knownKeys || knownKeys[key] === true) {
keys[target++] = key;
}
}
keys.length = target;
return keys.sort();
}
//# sourceMappingURL=queryKeyMaker.js.map
import { IdValue } from 'apollo-utilities';
import { Cache } from 'apollo-cache';
import { ReadStoreContext, DiffQueryAgainstStoreOptions, ReadQueryOptions } from './types';
import { ReadStoreContext, DiffQueryAgainstStoreOptions, ReadQueryOptions, StoreObject } from './types';
import { CacheKeyNode } from './optimism';

@@ -11,3 +11,3 @@ export { OptimisticWrapperFunction } from './optimism';

export declare type ExecResultMissingField = {
objectId: string;
object: StoreObject;
fieldName: string;

@@ -20,11 +20,6 @@ tolerable: boolean;

};
declare type StoreReaderOptions = {
addTypename?: boolean;
cacheKeyRoot?: CacheKeyNode;
};
export declare class StoreReader {
private addTypename;
private cacheKeyRoot;
private keyMaker;
constructor({ addTypename, cacheKeyRoot, }?: StoreReaderOptions);
constructor(cacheKeyRoot?: CacheKeyNode<object>);
readQueryFromStore<QueryType>(options: ReadQueryOptions): QueryType;

@@ -35,2 +30,3 @@ diffQueryAgainstStore<T>({ store, query, variables, previousResult, returnPartialData, rootId, fragmentMatcherFunction, config, }: DiffQueryAgainstStoreOptions): Cache.DiffResult<T>;

private executeField;
private combineExecResults;
private executeSubSelectedArray;

@@ -37,0 +33,0 @@ }

@@ -17,21 +17,22 @@ var __assign = (this && this.__assign) || function () {

var StoreReader = (function () {
function StoreReader(_a) {
var _b = _a === void 0 ? {} : _a, _c = _b.addTypename, addTypename = _c === void 0 ? false : _c, _d = _b.cacheKeyRoot, cacheKeyRoot = _d === void 0 ? new CacheKeyNode : _d;
function StoreReader(cacheKeyRoot) {
if (cacheKeyRoot === void 0) { cacheKeyRoot = new CacheKeyNode(); }
var _this = this;
this.cacheKeyRoot = cacheKeyRoot;
var reader = this;
var executeStoreQuery = reader.executeStoreQuery, executeSelectionSet = reader.executeSelectionSet;
reader.addTypename = addTypename;
reader.cacheKeyRoot = cacheKeyRoot;
reader.keyMaker = new QueryKeyMaker(cacheKeyRoot);
this.executeStoreQuery = wrap(function (options) {
return executeStoreQuery.call(reader, options);
return executeStoreQuery.call(_this, options);
}, {
makeCacheKey: function (_a) {
var query = _a.query, rootValue = _a.rootValue, contextValue = _a.contextValue, variableValues = _a.variableValues;
var query = _a.query, rootValue = _a.rootValue, contextValue = _a.contextValue, variableValues = _a.variableValues, fragmentMatcher = _a.fragmentMatcher;
if (contextValue.store instanceof DepTrackingCache) {
return reader.cacheKeyRoot.lookup(reader.keyMaker.forQuery(query).lookupQuery(query), contextValue.store, JSON.stringify(variableValues));
return reader.cacheKeyRoot.lookup(reader.keyMaker.forQuery(query).lookupQuery(query), contextValue.store, fragmentMatcher, JSON.stringify(variableValues), rootValue.id);
}
}
return;
},
});
this.executeSelectionSet = wrap(function (options) {
return executeSelectionSet.call(reader, options);
return executeSelectionSet.call(_this, options);
}, {

@@ -41,5 +42,8 @@ makeCacheKey: function (_a) {

if (execContext.contextValue.store instanceof DepTrackingCache) {
return reader.cacheKeyRoot.lookup(reader.keyMaker.forQuery(execContext.query).lookupSelectionSet(selectionSet), execContext.contextValue.store, JSON.stringify(execContext.variableValues), rootValue.id);
return reader.cacheKeyRoot.lookup(reader.keyMaker
.forQuery(execContext.query)
.lookupSelectionSet(selectionSet), execContext.contextValue.store, execContext.fragmentMatcher, JSON.stringify(execContext.variableValues), rootValue.id);
}
}
return;
},
});

@@ -77,3 +81,3 @@ }

return;
throw new Error("Can't find field " + info.fieldName + " on object (" + info.objectId + ") " + JSON.stringify(store.get(info.objectId), null, 2) + ".");
throw new Error("Can't find field " + info.fieldName + " on object " + JSON.stringify(info.object, null, 2) + ".");
});

@@ -92,3 +96,3 @@ }

StoreReader.prototype.executeStoreQuery = function (_a) {
var query = _a.query, rootValue = _a.rootValue, contextValue = _a.contextValue, variableValues = _a.variableValues, _b = _a.fragmentMatcher, fragmentMatcher = _b === void 0 ? function () { return true; } : _b;
var query = _a.query, rootValue = _a.rootValue, contextValue = _a.contextValue, variableValues = _a.variableValues, _b = _a.fragmentMatcher, fragmentMatcher = _b === void 0 ? defaultFragmentMatcher : _b;
var mainDefinition = getMainDefinition(query);

@@ -108,3 +112,2 @@ var fragments = getFragmentDefinitions(query);

execContext: execContext,
parentKind: mainDefinition.kind,
});

@@ -114,3 +117,3 @@ };

var _this = this;
var selectionSet = _a.selectionSet, rootValue = _a.rootValue, execContext = _a.execContext, parentKind = _a.parentKind;
var selectionSet = _a.selectionSet, rootValue = _a.rootValue, execContext = _a.execContext;
var fragmentMap = execContext.fragmentMap, contextValue = execContext.contextValue, variables = execContext.variableValues;

@@ -120,3 +123,7 @@ var finalResult = {

};
var didReadTypename = false;
var objectsToMerge = [];
var object = contextValue.store.get(rootValue.id);
var typename = (object && object.__typename) ||
(rootValue.id === 'ROOT_QUERY' && 'Query') ||
void 0;
function handleMissing(result) {

@@ -130,3 +137,3 @@ var _a;

}
var handleSelection = function (selection) {
selectionSet.selections.forEach(function (selection) {
var _a;

@@ -137,10 +144,6 @@ if (!shouldInclude(selection, variables)) {

if (isField(selection)) {
var fieldResult = handleMissing(_this.executeField(selection, rootValue, execContext));
var keyName = resultKeyNameFromField(selection);
if (keyName === "__typename") {
didReadTypename = true;
}
var fieldResult = handleMissing(_this.executeField(object, typename, selection, execContext));
if (typeof fieldResult !== 'undefined') {
merge(finalResult.result, (_a = {},
_a[keyName] = fieldResult,
objectsToMerge.push((_a = {},
_a[resultKeyNameFromField(selection)] = fieldResult,
_a));

@@ -167,3 +170,2 @@ }

execContext: execContext,
parentKind: fragment.kind,
});

@@ -175,21 +177,10 @@ if (match === 'heuristic' && fragmentExecResult.missing) {

}
merge(finalResult.result, handleMissing(fragmentExecResult));
objectsToMerge.push(handleMissing(fragmentExecResult));
}
}
};
selectionSet.selections.forEach(handleSelection);
if (!didReadTypename &&
this.addTypename &&
parentKind !== "OperationDefinition") {
handleSelection({
kind: "Field",
name: {
kind: "Name",
value: "__typename",
},
});
}
});
merge(finalResult.result, objectsToMerge);
return finalResult;
};
StoreReader.prototype.executeField = function (field, rootValue, execContext) {
StoreReader.prototype.executeField = function (object, typename, field, execContext) {
var variables = execContext.variableValues, contextValue = execContext.contextValue;

@@ -202,4 +193,8 @@ var fieldName = field.name.value;

};
var readStoreResult = readStoreResolver(fieldName, rootValue, args, contextValue, info);
var readStoreResult = readStoreResolver(object, typename, fieldName, args, contextValue, info);
if (Array.isArray(readStoreResult.result)) {
return this.combineExecResults(readStoreResult, this.executeSubSelectedArray(field, readStoreResult.result, execContext));
}
if (!field.selectionSet) {
assertSelectionSetForIdValue(field, readStoreResult.result);
return readStoreResult;

@@ -210,27 +205,25 @@ }

}
function handleMissing(res) {
var missing = null;
if (readStoreResult.missing) {
missing = missing || [];
missing.push.apply(missing, readStoreResult.missing);
}
if (res.missing) {
missing = missing || [];
missing.push.apply(missing, res.missing);
}
return {
result: res.result,
missing: missing,
};
}
if (Array.isArray(readStoreResult.result)) {
return handleMissing(this.executeSubSelectedArray(field, readStoreResult.result, execContext));
}
return handleMissing(this.executeSelectionSet({
return this.combineExecResults(readStoreResult, this.executeSelectionSet({
selectionSet: field.selectionSet,
rootValue: readStoreResult.result,
execContext: execContext,
parentKind: field.kind,
}));
};
StoreReader.prototype.combineExecResults = function () {
var execResults = [];
for (var _i = 0; _i < arguments.length; _i++) {
execResults[_i] = arguments[_i];
}
var missing = null;
execResults.forEach(function (execResult) {
if (execResult.missing) {
missing = missing || [];
missing.push.apply(missing, execResult.missing);
}
});
return {
result: execResults.pop().result,
missing: missing,
};
};
StoreReader.prototype.executeSubSelectedArray = function (field, result, execContext) {

@@ -253,8 +246,11 @@ var _this = this;

}
return handleMissing(_this.executeSelectionSet({
selectionSet: field.selectionSet,
rootValue: item,
execContext: execContext,
parentKind: field.kind,
}));
if (field.selectionSet) {
return handleMissing(_this.executeSelectionSet({
selectionSet: field.selectionSet,
rootValue: item,
execContext: execContext,
}));
}
assertSelectionSetForIdValue(field, item);
return item;
});

@@ -266,2 +262,10 @@ return { result: result, missing: missing };

export { StoreReader };
function assertSelectionSetForIdValue(field, value) {
if (!field.selectionSet && isIdValue(value)) {
throw new Error("Missing selection set for object of type " + value.typename + " returned for query field " + field.name.value);
}
}
function defaultFragmentMatcher() {
return true;
}
export function assertIdValue(idValue) {

@@ -272,7 +276,4 @@ if (!isIdValue(idValue)) {

}
function readStoreResolver(fieldName, idValue, args, context, _a) {
function readStoreResolver(object, typename, fieldName, args, context, _a) {
var resultKey = _a.resultKey, directives = _a.directives;
assertIdValue(idValue);
var objId = idValue.id;
var obj = context.store.get(objId);
var storeKeyName = fieldName;

@@ -283,8 +284,7 @@ if (args || directives) {

var fieldValue = void 0;
if (obj) {
fieldValue = obj[storeKeyName];
if (object) {
fieldValue = object[storeKeyName];
if (typeof fieldValue === 'undefined' &&
context.cacheRedirects &&
(obj.__typename || objId === 'ROOT_QUERY')) {
var typename = obj.__typename || 'Query';
typeof typename === 'string') {
var type = context.cacheRedirects[typename];

@@ -294,3 +294,3 @@ if (type) {

if (resolver) {
fieldValue = resolver(obj, args, {
fieldValue = resolver(object, args, {
getCacheKey: function (storeObj) {

@@ -310,7 +310,9 @@ return toIdValue({

result: fieldValue,
missing: [{
objectId: objId,
missing: [
{
object: object,
fieldName: storeKeyName,
tolerable: false,
}],
},
],
};

@@ -326,15 +328,24 @@ }

var hasOwn = Object.prototype.hasOwnProperty;
function merge(target, source) {
if (source !== null && typeof source === 'object' &&
source !== target) {
function merge(target, sources) {
var pastCopies = [];
sources.forEach(function (source) {
mergeHelper(target, source, pastCopies);
});
return target;
}
function mergeHelper(target, source, pastCopies) {
if (source !== null && typeof source === 'object') {
if (Object.isExtensible && !Object.isExtensible(target)) {
target = __assign({}, target);
target = shallowCopyForMerge(target, pastCopies);
}
Object.keys(source).forEach(function (sourceKey) {
var sourceVal = source[sourceKey];
if (!hasOwn.call(target, sourceKey)) {
target[sourceKey] = sourceVal;
var sourceValue = source[sourceKey];
if (hasOwn.call(target, sourceKey)) {
var targetValue = target[sourceKey];
if (sourceValue !== targetValue) {
target[sourceKey] = mergeHelper(shallowCopyForMerge(targetValue, pastCopies), sourceValue, pastCopies);
}
}
else {
target[sourceKey] = merge(target[sourceKey], sourceVal);
target[sourceKey] = sourceValue;
}

@@ -345,2 +356,16 @@ });

}
function shallowCopyForMerge(value, pastCopies) {
if (value !== null &&
typeof value === 'object' &&
pastCopies.indexOf(value) < 0) {
if (Array.isArray(value)) {
value = value.slice(0);
}
else {
value = __assign({}, value);
}
pastCopies.push(value);
}
return value;
}
//# sourceMappingURL=readFromStore.js.map

@@ -19,8 +19,3 @@ import { SelectionSetNode, FieldNode, DocumentNode } from 'graphql';

};
declare type StoreWriterOptions = {
addTypename?: boolean;
};
export declare class StoreWriter {
private addTypename;
constructor({ addTypename, }?: StoreWriterOptions);
writeQueryToStore({ query, result, store, variables, dataIdFromObject, fragmentMatcherFunction, }: {

@@ -43,3 +38,3 @@ query: DocumentNode;

}): NormalizedCache;
writeSelectionSetToStore({ result, dataId, selectionSet, context, parentKind, }: {
writeSelectionSetToStore({ result, dataId, selectionSet, context, }: {
dataId: string;

@@ -49,3 +44,2 @@ result: any;

context: WriteContext;
parentKind: string;
}): NormalizedCache;

@@ -55,3 +49,2 @@ private writeFieldToStore;

}
export {};
//# sourceMappingURL=writeToStore.d.ts.map

@@ -45,13 +45,4 @@ var __extends = (this && this.__extends) || (function () {

}
var TYPENAME_FIELD = {
kind: 'Field',
name: {
kind: 'Name',
value: '__typename',
},
};
var StoreWriter = (function () {
function StoreWriter(_a) {
var _b = (_a === void 0 ? {} : _a).addTypename, addTypename = _b === void 0 ? false : _b;
this.addTypename = addTypename;
function StoreWriter() {
}

@@ -86,3 +77,2 @@ StoreWriter.prototype.writeQueryToStore = function (_a) {

},
parentKind: operationDefinition.kind,
});

@@ -96,5 +86,4 @@ }

var _this = this;
var result = _a.result, dataId = _a.dataId, selectionSet = _a.selectionSet, context = _a.context, parentKind = _a.parentKind;
var result = _a.result, dataId = _a.dataId, selectionSet = _a.selectionSet, context = _a.context;
var variables = context.variables, store = context.store, fragmentMap = context.fragmentMap;
var didWriteTypename = false;
selectionSet.selections.forEach(function (selection) {

@@ -107,5 +96,2 @@ if (!shouldInclude(selection, variables)) {

var value = result[resultFieldKey];
if (resultFieldKey === "__typename") {
didWriteTypename = true;
}
if (typeof value !== 'undefined') {

@@ -120,6 +106,9 @@ _this.writeFieldToStore({

else {
var isDefered = selection.directives &&
selection.directives.length &&
selection.directives.some(function (directive) { return directive.name && directive.name.value === 'defer'; });
if (!isDefered && context.fragmentMatcherFunction) {
var isDefered = false;
var isClient = false;
if (selection.directives && selection.directives.length) {
isDefered = selection.directives.some(function (directive) { return directive.name && directive.name.value === 'defer'; });
isClient = selection.directives.some(function (directive) { return directive.name && directive.name.value === 'client'; });
}
if (!isDefered && !isClient && context.fragmentMatcherFunction) {
if (!isProduction()) {

@@ -161,3 +150,2 @@ console.warn("Missing field " + resultFieldKey + " in " + JSON.stringify(result, null, 2).substring(0, 100));

context: context,
parentKind: fragment.kind,
});

@@ -167,13 +155,2 @@ }

});
if (!didWriteTypename &&
this.addTypename &&
parentKind !== "OperationDefinition" &&
typeof result.__typename === "string") {
this.writeFieldToStore({
dataId: dataId,
value: result.__typename,
field: TYPENAME_FIELD,
context: context,
});
}
return store;

@@ -198,3 +175,3 @@ };

var generatedId = dataId + "." + storeFieldName;
storeValue = this.processArrayValue(value, generatedId, field.selectionSet, context, field.kind);
storeValue = this.processArrayValue(value, generatedId, field.selectionSet, context);
}

@@ -224,3 +201,2 @@ else {

context: context,
parentKind: field.kind,
});

@@ -265,3 +241,3 @@ }

};
StoreWriter.prototype.processArrayValue = function (value, generatedId, selectionSet, context, parentKind) {
StoreWriter.prototype.processArrayValue = function (value, generatedId, selectionSet, context) {
var _this = this;

@@ -274,3 +250,3 @@ return value.map(function (item, index) {

if (Array.isArray(item)) {
return _this.processArrayValue(item, itemDataId, selectionSet, context, parentKind);
return _this.processArrayValue(item, itemDataId, selectionSet, context);
}

@@ -291,3 +267,2 @@ var generated = true;

context: context,
parentKind: parentKind,
});

@@ -294,0 +269,0 @@ }

{
"name": "apollo-cache-inmemory",
"version": "1.4.0-alpha.1",
"version": "1.4.0-alpha.2",
"description": "Core abstract of Caching layer for Apollo Client",

@@ -18,3 +18,5 @@ "author": "James Baxley <james@meteor.com>",

"typings": "./lib/index.d.ts",
"sideEffects": false,
"sideEffects": [
"./lib/fixPolyfills.js"
],
"repository": {

@@ -44,8 +46,8 @@ "type": "git",

"dependencies": {
"apollo-cache": "^1.2.0-alpha.1",
"apollo-utilities": "^1.1.0-alpha.1",
"apollo-cache": "^1.2.0-alpha.2",
"apollo-utilities": "^1.1.0-alpha.2",
"optimism": "^0.6.6"
},
"peerDependencies": {
"graphql": "0.11.7 || ^0.12.0 || ^0.13.0"
"graphql": "0.11.7 || ^0.12.0 || ^0.13.0 || ^14.0.0"
},

@@ -65,3 +67,3 @@ "jest": {

},
"gitHead": "cc787f8f294943fe1f1b8de427ed9a70725744f6"
"gitHead": "a3e32b0ec42d221d443b402d108b428c53975d05"
}

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc