-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3964 from apollographql/include-root-ID-in-execut…
…eStoreQuery-cache-key Fix various apollo-cache-inmemory 1.3.x bugs.
- Loading branch information
Showing
8 changed files
with
139 additions
and
154 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "apollo-cache-inmemory", | ||
"version": "1.3.0", | ||
"version": "1.3.5", | ||
"description": "Core abstract of Caching layer for Apollo Client", | ||
"author": "James Baxley <[email protected]>", | ||
"contributors": [ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
const frozen = {}; | ||
const frozenTestMap = new Map(); | ||
|
||
if (typeof Object.freeze === 'function') { | ||
Object.freeze(frozen); | ||
} | ||
|
||
try { | ||
// If non-extensible objects can't be stored as keys in a Map, make sure we | ||
// do not freeze/seal/etc. an object without first attempting to put it in a | ||
// Map. For example, this gives the React Native Map polyfill a chance to tag | ||
// objects before they become non-extensible: | ||
// https://github.com/facebook/react-native/blob/98a6f19d7c/Libraries/vendor/core/Map.js#L44-L50 | ||
// https://github.com/apollographql/react-apollo/issues/2442#issuecomment-426489517 | ||
frozenTestMap.set(frozen, frozen).delete(frozen); | ||
} catch { | ||
const wrap = (method: <T>(obj: T) => T): typeof method => { | ||
return method && (obj => { | ||
try { | ||
// If .set succeeds, also call .delete to avoid leaking memory. | ||
frozenTestMap.set(obj, obj).delete(obj); | ||
} finally { | ||
// If .set or .delete fails, the exception will be silently swallowed | ||
// by this return-from-finally statement: | ||
return method.call(Object, obj); | ||
} | ||
}); | ||
}; | ||
Object.freeze = wrap(Object.freeze); | ||
Object.seal = wrap(Object.seal); | ||
Object.preventExtensions = wrap(Object.preventExtensions); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.