Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eliminate "generated" cache IDs to avoid normalizing objects without meaningful IDs. #5146

Merged
merged 38 commits into from
Aug 9, 2019
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
0af6233
Use Reference instances instead of duck-typing IdValue objects.
benjamn Aug 2, 2019
53f5d1a
Stop escaping JSON blobs in the cache.
benjamn Aug 2, 2019
e6d6b88
Batch-update StoreObject fields in writeSelectionSetToStore.
benjamn Aug 2, 2019
dad47a3
Pass storeObject into writeFieldToStore.
benjamn Aug 2, 2019
654e6c7
Move bulk of writeSelectionSetToStore into processSelectionSet.
benjamn Aug 2, 2019
80c1cdb
Pass storeObject into processSelectionSet.
benjamn Aug 2, 2019
9dcb034
Stop calling writeSelectionSetToStore from processSelectionSet.
benjamn Aug 2, 2019
d2f1fc5
Stop using dataId in processSelectionSet except to call writeFieldToS…
benjamn Aug 2, 2019
10f5012
Move generated ID logic from writeFieldToStore to writeSelectionSetTo…
benjamn Aug 5, 2019
b6ac62c
Move bulk of writeFieldToStore into processFieldValue method.
benjamn Aug 5, 2019
fe2408d
Merge processArrayValue into processFieldValue.
benjamn Aug 5, 2019
6a1aeae
Inline private writeFieldToStore method.
benjamn Aug 5, 2019
b64d253
Stop prepending $ to generated cache IDs.
benjamn Aug 5, 2019
62ba47d
Allow reading non-IdValue objects from the cache.
benjamn Aug 5, 2019
26d9d75
Unpack first element of arrays when asserting selectionSet.
benjamn Aug 7, 2019
085b43a
Use defaultDataIdFromObject when calling writeResultToStore directly.
benjamn Aug 7, 2019
315d510
Remove the concept of generated IDs from the cache.
benjamn Aug 5, 2019
78aaa59
Disallow creating generated Reference instances.
benjamn Aug 7, 2019
feb9f36
Make mergeDeep support custom reconciliation functions.
benjamn Aug 7, 2019
c87f447
Reimplement mergeStoreObjects using DeepMerger reconciliation function.
benjamn Aug 7, 2019
578b2d1
Truncate existing arrays to match length of incoming arrays.
benjamn Aug 7, 2019
58f297b
Export makeReference and isReference from apollo-cache-inmemory.
benjamn Aug 7, 2019
8c7e1a4
Eliminate redundant StoreWriter#writeResultToStore method.
benjamn Aug 7, 2019
753a606
Simplify isDataProcessed logic using Set<FieldNode>.
benjamn Aug 7, 2019
906c4bf
Fix apollo-client tests that depend on internal cache representation.
benjamn Aug 7, 2019
3adb970
Update Jest snapshots in apollo-client tests after PR #5146.
benjamn Aug 7, 2019
75526a3
Tighten bundle size limits following recent improvements.
benjamn Aug 7, 2019
29699ce
Stop calling shallowCopyForMerge in DeepMerger test.
benjamn Aug 7, 2019
5ce3339
Remove dataIdFromObject test that deliberately sidesteps TypeScript.
benjamn Aug 8, 2019
ada838c
Simplify Array.isArray case in processFieldValue.
benjamn Aug 8, 2019
a263eef
Make better guarantees in assertSelectionSetForIdValue.
benjamn Aug 8, 2019
3c6b155
More (non-throwing) tests of assertSelectionSetForIdValue.
benjamn Aug 8, 2019
01e0cc5
Make entity references trivially (de)serializable.
benjamn Aug 8, 2019
a5ca898
Fix apollo-client tests after Reference => { __ref } refactor.
benjamn Aug 8, 2019
1376882
Derive __typename from result objects more reliably.
benjamn Aug 8, 2019
8a2e678
Increase bundle size limit for apollo-utilities from 4.1 to 4.25KB.
benjamn Aug 8, 2019
db9537a
Rename references.ts to helpers.ts.
benjamn Aug 9, 2019
054eb7b
Remove unused assertIdValue function.
benjamn Aug 9, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,17 @@
{
"name": "apollo-cache-inmemory",
"path": "./packages/apollo-cache-inmemory/lib/bundle.cjs.min.js",
"maxSize": "5.05 kB"
"maxSize": "4.3 kB"
},
{
"name": "apollo-client",
"path": "./packages/apollo-client/lib/bundle.cjs.min.js",
"maxSize": "9.95 kB"
"maxSize": "9.9 kB"
},
{
"name": "apollo-utilities",
"path": "./packages/apollo-utilities/lib/bundle.cjs.min.js",
"maxSize": "4.2 kB"
"maxSize": "4.1 kB"
}
],
"lint-staged": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Object {
},
"foo": Object {
"e": 4,
"h": Object {
"h": Reference {
"generated": false,
"id": "bar",
"type": "id",
Expand All @@ -28,7 +28,7 @@ Object {
"e": 4,
"f": 5,
"g": 6,
"h": Object {
"h": Reference {
"generated": false,
"id": "bar",
"type": "id",
Expand All @@ -49,7 +49,7 @@ Object {
"e": 4,
"f": 5,
"g": 6,
"h": Object {
"h": Reference {
"generated": false,
"id": "bar",
"type": "id",
Expand All @@ -70,7 +70,7 @@ Object {
"e": 4,
"f": 5,
"g": 6,
"h": Object {
"h": Reference {
"generated": false,
"id": "bar",
"type": "id",
Expand All @@ -91,7 +91,7 @@ Object {
"e": 4,
"f": 5,
"g": 6,
"h": Object {
"h": Reference {
"generated": false,
"id": "bar",
"type": "id",
Expand All @@ -112,7 +112,7 @@ Object {
"e": 4,
"f": 5,
"g": 6,
"h": Object {
"h": Reference {
"generated": false,
"id": "bar",
"type": "id",
Expand All @@ -129,7 +129,7 @@ Object {
},
"foo": Object {
"e": 4,
"h": Object {
"h": Reference {
"generated": false,
"id": "bar",
"type": "id",
Expand All @@ -150,7 +150,7 @@ Object {
"e": 4,
"f": 5,
"g": 6,
"h": Object {
"h": Reference {
"generated": false,
"id": "bar",
"type": "id",
Expand All @@ -171,7 +171,7 @@ Object {
"e": 4,
"f": 5,
"g": 6,
"h": Object {
"h": Reference {
"generated": false,
"id": "bar",
"type": "id",
Expand All @@ -192,7 +192,7 @@ Object {
"e": 4,
"f": 5,
"g": 6,
"h": Object {
"h": Reference {
"generated": false,
"id": "bar",
"type": "id",
Expand All @@ -213,7 +213,7 @@ Object {
"e": 4,
"f": 5,
"g": 6,
"h": Object {
"h": Reference {
"generated": false,
"id": "bar",
"type": "id",
Expand All @@ -234,7 +234,7 @@ Object {
"e": 4,
"f": 5,
"g": 6,
"h": Object {
"h": Reference {
"generated": false,
"id": "bar",
"type": "id",
Expand All @@ -251,7 +251,7 @@ Object {
},
"foo": Object {
"e": 4,
"h": Object {
"h": Reference {
"generated": false,
"id": "bar",
"type": "id",
Expand All @@ -272,7 +272,7 @@ Object {
"e": 4,
"f": 5,
"g": 6,
"h": Object {
"h": Reference {
"generated": false,
"id": "bar",
"type": "id",
Expand All @@ -293,7 +293,7 @@ Object {
"e": 4,
"f": 5,
"g": 6,
"h": Object {
"h": Reference {
"generated": false,
"id": "bar",
"type": "id",
Expand All @@ -314,7 +314,7 @@ Object {
"e": 4,
"f": 5,
"g": 6,
"h": Object {
"h": Reference {
"generated": false,
"id": "bar",
"type": "id",
Expand All @@ -335,7 +335,7 @@ Object {
"e": 4,
"f": 5,
"g": 6,
"h": Object {
"h": Reference {
"generated": false,
"id": "bar",
"type": "id",
Expand All @@ -356,7 +356,7 @@ Object {
"e": 4,
"f": 5,
"g": 6,
"h": Object {
"h": Reference {
"generated": false,
"id": "bar",
"type": "id",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Object {
},
"foo": Object {
"e": 4,
"h": Object {
"h": Reference {
"generated": false,
"id": "bar",
"type": "id",
Expand All @@ -28,7 +28,7 @@ Object {
"e": 4,
"f": 5,
"g": 6,
"h": Object {
"h": Reference {
"generated": false,
"id": "bar",
"type": "id",
Expand All @@ -49,7 +49,7 @@ Object {
"e": 4,
"f": 5,
"g": 6,
"h": Object {
"h": Reference {
"generated": false,
"id": "bar",
"type": "id",
Expand All @@ -70,7 +70,7 @@ Object {
"e": 4,
"f": 5,
"g": 6,
"h": Object {
"h": Reference {
"generated": false,
"id": "bar",
"type": "id",
Expand All @@ -91,7 +91,7 @@ Object {
"e": 4,
"f": 5,
"g": 6,
"h": Object {
"h": Reference {
"generated": false,
"id": "bar",
"type": "id",
Expand All @@ -112,7 +112,7 @@ Object {
"e": 4,
"f": 5,
"g": 6,
"h": Object {
"h": Reference {
"generated": false,
"id": "bar",
"type": "id",
Expand All @@ -129,7 +129,7 @@ Object {
},
"foo": Object {
"e": 4,
"h": Object {
"h": Reference {
"generated": false,
"id": "bar",
"type": "id",
Expand All @@ -150,7 +150,7 @@ Object {
"e": 4,
"f": 5,
"g": 6,
"h": Object {
"h": Reference {
"generated": false,
"id": "bar",
"type": "id",
Expand All @@ -171,7 +171,7 @@ Object {
"e": 4,
"f": 5,
"g": 6,
"h": Object {
"h": Reference {
"generated": false,
"id": "bar",
"type": "id",
Expand All @@ -192,7 +192,7 @@ Object {
"e": 4,
"f": 5,
"g": 6,
"h": Object {
"h": Reference {
"generated": false,
"id": "bar",
"type": "id",
Expand All @@ -213,7 +213,7 @@ Object {
"e": 4,
"f": 5,
"g": 6,
"h": Object {
"h": Reference {
"generated": false,
"id": "bar",
"type": "id",
Expand All @@ -234,7 +234,7 @@ Object {
"e": 4,
"f": 5,
"g": 6,
"h": Object {
"h": Reference {
"generated": false,
"id": "bar",
"type": "id",
Expand All @@ -251,7 +251,7 @@ Object {
},
"foo": Object {
"e": 4,
"h": Object {
"h": Reference {
"generated": false,
"id": "bar",
"type": "id",
Expand All @@ -272,7 +272,7 @@ Object {
"e": 4,
"f": 5,
"g": 6,
"h": Object {
"h": Reference {
"generated": false,
"id": "bar",
"type": "id",
Expand All @@ -293,7 +293,7 @@ Object {
"e": 4,
"f": 5,
"g": 6,
"h": Object {
"h": Reference {
"generated": false,
"id": "bar",
"type": "id",
Expand All @@ -314,7 +314,7 @@ Object {
"e": 4,
"f": 5,
"g": 6,
"h": Object {
"h": Reference {
"generated": false,
"id": "bar",
"type": "id",
Expand All @@ -335,7 +335,7 @@ Object {
"e": 4,
"f": 5,
"g": 6,
"h": Object {
"h": Reference {
"generated": false,
"id": "bar",
"type": "id",
Expand All @@ -356,7 +356,7 @@ Object {
"e": 4,
"f": 5,
"g": 6,
"h": Object {
"h": Reference {
"generated": false,
"id": "bar",
"type": "id",
Expand All @@ -369,6 +369,5 @@ Object {
exports[`MapCache writing to the store throws when trying to write an object without id that was previously queried with id 1`] = `
"Error writing result to store for query:
{\\"kind\\":\\"Document\\",\\"definitions\\":[{\\"kind\\":\\"OperationDefinition\\",\\"operation\\":\\"query\\",\\"name\\":{\\"kind\\":\\"Name\\",\\"value\\":\\"Failure\\"},\\"variableDefinitions\\":[],\\"directives\\":[],\\"selectionSet\\":{\\"kind\\":\\"SelectionSet\\",\\"selections\\":[{\\"kind\\":\\"Field\\",\\"name\\":{\\"kind\\":\\"Name\\",\\"value\\":\\"item\\"},\\"arguments\\":[],\\"directives\\":[],\\"selectionSet\\":{\\"kind\\":\\"SelectionSet\\",\\"selections\\":[{\\"kind\\":\\"Field\\",\\"name\\":{\\"kind\\":\\"Name\\",\\"value\\":\\"stringField\\"},\\"arguments\\":[],\\"directives\\":[]}]}}]}}],\\"loc\\":{\\"start\\":0,\\"end\\":106}}
Store error: the application attempted to write an object with no provided id but the store already contains an id of abcd for this object. The selectionSet that was trying to be written is:
{\\"kind\\":\\"Field\\",\\"name\\":{\\"kind\\":\\"Name\\",\\"value\\":\\"item\\"},\\"arguments\\":[],\\"directives\\":[],\\"selectionSet\\":{\\"kind\\":\\"SelectionSet\\",\\"selections\\":[{\\"kind\\":\\"Field\\",\\"name\\":{\\"kind\\":\\"Name\\",\\"value\\":\\"stringField\\"},\\"arguments\\":[],\\"directives\\":[]}]}}"
Store error: the application attempted to write an object with no provided id but the store already contains an id of abcd for this object."
`;
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[
`writing to the store throws when trying to write an object without id that was previously queried with id 1`
] = `
exports[`writing to the store throws when trying to write an object without id that was previously queried with id 1`] = `
"Error writing result to store for query:
{\\"kind\\":\\"Document\\",\\"definitions\\":[{\\"kind\\":\\"OperationDefinition\\",\\"operation\\":\\"query\\",\\"name\\":{\\"kind\\":\\"Name\\",\\"value\\":\\"Failure\\"},\\"variableDefinitions\\":[],\\"directives\\":[],\\"selectionSet\\":{\\"kind\\":\\"SelectionSet\\",\\"selections\\":[{\\"kind\\":\\"Field\\",\\"name\\":{\\"kind\\":\\"Name\\",\\"value\\":\\"item\\"},\\"arguments\\":[],\\"directives\\":[],\\"selectionSet\\":{\\"kind\\":\\"SelectionSet\\",\\"selections\\":[{\\"kind\\":\\"Field\\",\\"name\\":{\\"kind\\":\\"Name\\",\\"value\\":\\"stringField\\"},\\"arguments\\":[],\\"directives\\":[]}]}}]}}],\\"loc\\":{\\"start\\":0,\\"end\\":106}}
Store error: the application attempted to write an object with no provided id but the store already contains an id of abcd for this object. The selectionSet that was trying to be written is:
{\\"kind\\":\\"Field\\",\\"name\\":{\\"kind\\":\\"Name\\",\\"value\\":\\"item\\"},\\"arguments\\":[],\\"directives\\":[],\\"selectionSet\\":{\\"kind\\":\\"SelectionSet\\",\\"selections\\":[{\\"kind\\":\\"Field\\",\\"name\\":{\\"kind\\":\\"Name\\",\\"value\\":\\"stringField\\"},\\"arguments\\":[],\\"directives\\":[]}]}}"
Store error: the application attempted to write an object with no provided id but the store already contains an id of abcd for this object."
`;
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[
`writing to the store throws when trying to write an object without id that was previously queried with id 1`
] = `
exports[`writing to the store throws when trying to write an object without id that was previously queried with id 1`] = `
"Error writing result to store for query:
{\\"kind\\":\\"Document\\",\\"definitions\\":[{\\"kind\\":\\"OperationDefinition\\",\\"operation\\":\\"query\\",\\"name\\":{\\"kind\\":\\"Name\\",\\"value\\":\\"Failure\\"},\\"variableDefinitions\\":[],\\"directives\\":[],\\"selectionSet\\":{\\"kind\\":\\"SelectionSet\\",\\"selections\\":[{\\"kind\\":\\"Field\\",\\"name\\":{\\"kind\\":\\"Name\\",\\"value\\":\\"item\\"},\\"arguments\\":[],\\"directives\\":[],\\"selectionSet\\":{\\"kind\\":\\"SelectionSet\\",\\"selections\\":[{\\"kind\\":\\"Field\\",\\"name\\":{\\"kind\\":\\"Name\\",\\"value\\":\\"stringField\\"},\\"arguments\\":[],\\"directives\\":[]}]}}]}}],\\"loc\\":{\\"start\\":0,\\"end\\":106}}
Store error: the application attempted to write an object with no provided id but the store already contains an id of abcd for this object. The selectionSet that was trying to be written is:
{\\"kind\\":\\"Field\\",\\"name\\":{\\"kind\\":\\"Name\\",\\"value\\":\\"item\\"},\\"arguments\\":[],\\"directives\\":[],\\"selectionSet\\":{\\"kind\\":\\"SelectionSet\\",\\"selections\\":[{\\"kind\\":\\"Field\\",\\"name\\":{\\"kind\\":\\"Name\\",\\"value\\":\\"stringField\\"},\\"arguments\\":[],\\"directives\\":[]}]}}"
Store error: the application attempted to write an object with no provided id but the store already contains an id of abcd for this object."
`;
Loading