apollo-cache-inmemory
Advanced tools
Comparing version 1.3.0-beta.12 to 1.3.0-beta.13
@@ -886,3 +886,3 @@ (function (global, factory) { | ||
} | ||
}, | ||
} | ||
}); | ||
@@ -908,3 +908,3 @@ return _this; | ||
} | ||
var store = query.optimistic && this.optimistic.length | ||
var store = (query.optimistic && this.optimistic.length) | ||
? defaultNormalizedCacheFactory$1(this.extract(true)) | ||
@@ -935,3 +935,3 @@ : this.data; | ||
InMemoryCache.prototype.diff = function (query) { | ||
var store = query.optimistic && this.optimistic.length | ||
var store = (query.optimistic && this.optimistic.length) | ||
? defaultNormalizedCacheFactory$1(this.extract(true)) | ||
@@ -1062,3 +1062,4 @@ : this.data; | ||
}); | ||
if (previousResult && previousResult === newData.result) { | ||
if (previousResult && | ||
previousResult === newData.result) { | ||
return; | ||
@@ -1065,0 +1066,0 @@ } |
@@ -30,4 +30,4 @@ var __extends = (this && this.__extends) || (function () { | ||
import { StoreReader } from './readFromStore'; | ||
import { defaultNormalizedCacheFactory, DepTrackingCache, } from './depTrackingCache'; | ||
import { wrap, defaultMakeCacheKey, } from './optimism'; | ||
import { defaultNormalizedCacheFactory, DepTrackingCache } from './depTrackingCache'; | ||
import { wrap, defaultMakeCacheKey, } from "./optimism"; | ||
import { record } from './recordingCache'; | ||
@@ -86,3 +86,3 @@ var defaultConfig = { | ||
} | ||
}, | ||
} | ||
}); | ||
@@ -108,3 +108,3 @@ return _this; | ||
} | ||
var store = query.optimistic && this.optimistic.length | ||
var store = (query.optimistic && this.optimistic.length) | ||
? defaultNormalizedCacheFactory(this.extract(true)) | ||
@@ -135,3 +135,3 @@ : this.data; | ||
InMemoryCache.prototype.diff = function (query) { | ||
var store = query.optimistic && this.optimistic.length | ||
var store = (query.optimistic && this.optimistic.length) | ||
? defaultNormalizedCacheFactory(this.extract(true)) | ||
@@ -262,3 +262,4 @@ : this.data; | ||
}); | ||
if (previousResult && previousResult === newData.result) { | ||
if (previousResult && | ||
previousResult === newData.result) { | ||
return; | ||
@@ -265,0 +266,0 @@ } |
{ | ||
"name": "apollo-cache-inmemory", | ||
"version": "1.3.0-beta.12", | ||
"version": "1.3.0-beta.13", | ||
"description": "Core abstract of Caching layer for Apollo Client", | ||
@@ -5,0 +5,0 @@ "author": "James Baxley <james@meteor.com>", |
@@ -20,11 +20,8 @@ import { DocumentNode } from 'graphql'; | ||
import { StoreReader } from './readFromStore'; | ||
import { defaultNormalizedCacheFactory, DepTrackingCache } from './depTrackingCache'; | ||
import { | ||
defaultNormalizedCacheFactory, | ||
DepTrackingCache, | ||
} from './depTrackingCache'; | ||
import { | ||
wrap, | ||
defaultMakeCacheKey, | ||
OptimisticWrapperFunction, | ||
} from './optimism'; | ||
} from "./optimism"; | ||
@@ -89,30 +86,30 @@ import { record } from './recordingCache'; | ||
const { maybeBroadcastWatch } = cache; | ||
this.maybeBroadcastWatch = wrap( | ||
(c: Cache.WatchOptions) => { | ||
return maybeBroadcastWatch.call(this, c); | ||
}, | ||
{ | ||
makeCacheKey(c: Cache.WatchOptions) { | ||
if (c.optimistic && cache.optimistic.length > 0) { | ||
// If we're reading optimistic data, it doesn't matter if this.data | ||
// is a DepTrackingCache, since it will be ignored. | ||
return; | ||
} | ||
this.maybeBroadcastWatch = wrap((c: Cache.WatchOptions) => { | ||
return maybeBroadcastWatch.call(this, c); | ||
}, { | ||
makeCacheKey(c: Cache.WatchOptions) { | ||
if (c.optimistic && cache.optimistic.length > 0) { | ||
// If we're reading optimistic data, it doesn't matter if this.data | ||
// is a DepTrackingCache, since it will be ignored. | ||
return; | ||
} | ||
if (c.previousResult) { | ||
// If a previousResult was provided, assume the caller would prefer | ||
// to compare the previous data to the new data to determine whether | ||
// to broadcast, so we should disable caching by returning here, to | ||
// give maybeBroadcastWatch a chance to do that comparison. | ||
return; | ||
} | ||
if (c.previousResult) { | ||
// If a previousResult was provided, assume the caller would prefer | ||
// to compare the previous data to the new data to determine whether | ||
// to broadcast, so we should disable caching by returning here, to | ||
// give maybeBroadcastWatch a chance to do that comparison. | ||
return; | ||
} | ||
if (cache.data instanceof DepTrackingCache) { | ||
// Return a cache key (thus enabling caching) only if we're currently | ||
// using a data store that can track cache dependencies. | ||
return defaultMakeCacheKey(c.query, JSON.stringify(c.variables)); | ||
} | ||
}, | ||
}, | ||
); | ||
if (cache.data instanceof DepTrackingCache) { | ||
// Return a cache key (thus enabling caching) only if we're currently | ||
// using a data store that can track cache dependencies. | ||
return defaultMakeCacheKey( | ||
c.query, | ||
JSON.stringify(c.variables), | ||
); | ||
} | ||
} | ||
}); | ||
} | ||
@@ -139,6 +136,5 @@ | ||
const store = | ||
query.optimistic && this.optimistic.length | ||
? defaultNormalizedCacheFactory(this.extract(true)) | ||
: this.data; | ||
const store = (query.optimistic && this.optimistic.length) | ||
? defaultNormalizedCacheFactory(this.extract(true)) | ||
: this.data; | ||
@@ -171,6 +167,5 @@ return this.storeReader.readQueryFromStore({ | ||
public diff<T>(query: Cache.DiffOptions): Cache.DiffResult<T> { | ||
const store = | ||
query.optimistic && this.optimistic.length | ||
? defaultNormalizedCacheFactory(this.extract(true)) | ||
: this.data; | ||
const store = (query.optimistic && this.optimistic.length) | ||
? defaultNormalizedCacheFactory(this.extract(true)) | ||
: this.data; | ||
@@ -355,3 +350,4 @@ return this.storeReader.diffQueryAgainstStore({ | ||
if (previousResult && previousResult === newData.result) { | ||
if (previousResult && | ||
previousResult === newData.result) { | ||
return; | ||
@@ -358,0 +354,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 not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
458496
9646