Skip to content

Commit

Permalink
Merge pull request #4514 from apollographql/InMemoryCache-freezeResul…
Browse files Browse the repository at this point in the history
…ts-option

Support InMemoryCache({ freezeResults: true }) to help enforce immutability.
  • Loading branch information
benjamn authored Feb 28, 2019
2 parents f65e1f0 + b1acbce commit 525d9ec
Show file tree
Hide file tree
Showing 8 changed files with 373 additions and 45 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
**Note:** This is a cumulative changelog that outlines all of the Apollo Client project child package changes that were bundled into a specific `apollo-client` release.

## Apollo Client vNEXT

### Apollo Cache In-Memory

- Support `new InMemoryCache({ freezeResults: true })` to help enforce immutability. <br/>
[@benjamn](https://github.com/benjamn) in [#4514](https://github.com/apollographql/apollo-client/pull/4514)

## Apollo Client 2.5.1

### apollo-client 2.5.1
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
{
"name": "apollo-cache-inmemory",
"path": "./packages/apollo-cache-inmemory/lib/bundle.cjs.min.js",
"maxSize": "4.9 kB"
"maxSize": "4.95 kB"
},
{
"name": "apollo-client",
Expand Down
146 changes: 134 additions & 12 deletions packages/apollo-cache-inmemory/src/__tests__/__snapshots__/cache.ts.snap
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Cache writeFragment will write some deeply nested data into the store at any id (1/2) 1`] = `
exports[`Cache writeFragment will write some deeply nested data into the store at any id (1/3) 1`] = `
Object {
"bar": Object {
"i": 7,
Expand All @@ -17,7 +17,7 @@ Object {
}
`;

exports[`Cache writeFragment will write some deeply nested data into the store at any id (1/2) 2`] = `
exports[`Cache writeFragment will write some deeply nested data into the store at any id (1/3) 2`] = `
Object {
"bar": Object {
"i": 7,
Expand All @@ -38,7 +38,7 @@ Object {
}
`;

exports[`Cache writeFragment will write some deeply nested data into the store at any id (1/2) 3`] = `
exports[`Cache writeFragment will write some deeply nested data into the store at any id (1/3) 3`] = `
Object {
"bar": Object {
"i": 10,
Expand All @@ -59,7 +59,7 @@ Object {
}
`;

exports[`Cache writeFragment will write some deeply nested data into the store at any id (1/2) 4`] = `
exports[`Cache writeFragment will write some deeply nested data into the store at any id (1/3) 4`] = `
Object {
"bar": Object {
"i": 10,
Expand All @@ -80,7 +80,7 @@ Object {
}
`;

exports[`Cache writeFragment will write some deeply nested data into the store at any id (1/2) 5`] = `
exports[`Cache writeFragment will write some deeply nested data into the store at any id (1/3) 5`] = `
Object {
"bar": Object {
"i": 7,
Expand All @@ -101,7 +101,7 @@ Object {
}
`;

exports[`Cache writeFragment will write some deeply nested data into the store at any id (1/2) 6`] = `
exports[`Cache writeFragment will write some deeply nested data into the store at any id (1/3) 6`] = `
Object {
"bar": Object {
"i": 10,
Expand All @@ -122,7 +122,7 @@ Object {
}
`;

exports[`Cache writeFragment will write some deeply nested data into the store at any id (2/2) 1`] = `
exports[`Cache writeFragment will write some deeply nested data into the store at any id (2/3) 1`] = `
Object {
"bar": Object {
"i": 7,
Expand All @@ -139,7 +139,7 @@ Object {
}
`;

exports[`Cache writeFragment will write some deeply nested data into the store at any id (2/2) 2`] = `
exports[`Cache writeFragment will write some deeply nested data into the store at any id (2/3) 2`] = `
Object {
"bar": Object {
"i": 7,
Expand All @@ -160,7 +160,7 @@ Object {
}
`;

exports[`Cache writeFragment will write some deeply nested data into the store at any id (2/2) 3`] = `
exports[`Cache writeFragment will write some deeply nested data into the store at any id (2/3) 3`] = `
Object {
"bar": Object {
"i": 10,
Expand All @@ -181,7 +181,7 @@ Object {
}
`;

exports[`Cache writeFragment will write some deeply nested data into the store at any id (2/2) 4`] = `
exports[`Cache writeFragment will write some deeply nested data into the store at any id (2/3) 4`] = `
Object {
"bar": Object {
"i": 10,
Expand All @@ -202,7 +202,7 @@ Object {
}
`;

exports[`Cache writeFragment will write some deeply nested data into the store at any id (2/2) 5`] = `
exports[`Cache writeFragment will write some deeply nested data into the store at any id (2/3) 5`] = `
Object {
"bar": Object {
"i": 7,
Expand All @@ -223,7 +223,129 @@ Object {
}
`;

exports[`Cache writeFragment will write some deeply nested data into the store at any id (2/2) 6`] = `
exports[`Cache writeFragment will write some deeply nested data into the store at any id (2/3) 6`] = `
Object {
"bar": Object {
"i": 10,
"j": 11,
"k": 12,
},
"foo": Object {
"e": 4,
"f": 5,
"g": 6,
"h": Object {
"generated": false,
"id": "bar",
"type": "id",
"typename": "Bar",
},
},
}
`;

exports[`Cache writeFragment will write some deeply nested data into the store at any id (3/3) 1`] = `
Object {
"bar": Object {
"i": 7,
},
"foo": Object {
"e": 4,
"h": Object {
"generated": false,
"id": "bar",
"type": "id",
"typename": undefined,
},
},
}
`;

exports[`Cache writeFragment will write some deeply nested data into the store at any id (3/3) 2`] = `
Object {
"bar": Object {
"i": 7,
"j": 8,
"k": 9,
},
"foo": Object {
"e": 4,
"f": 5,
"g": 6,
"h": Object {
"generated": false,
"id": "bar",
"type": "id",
"typename": undefined,
},
},
}
`;

exports[`Cache writeFragment will write some deeply nested data into the store at any id (3/3) 3`] = `
Object {
"bar": Object {
"i": 10,
"j": 8,
"k": 9,
},
"foo": Object {
"e": 4,
"f": 5,
"g": 6,
"h": Object {
"generated": false,
"id": "bar",
"type": "id",
"typename": undefined,
},
},
}
`;

exports[`Cache writeFragment will write some deeply nested data into the store at any id (3/3) 4`] = `
Object {
"bar": Object {
"i": 10,
"j": 11,
"k": 12,
},
"foo": Object {
"e": 4,
"f": 5,
"g": 6,
"h": Object {
"generated": false,
"id": "bar",
"type": "id",
"typename": undefined,
},
},
}
`;

exports[`Cache writeFragment will write some deeply nested data into the store at any id (3/3) 5`] = `
Object {
"bar": Object {
"i": 7,
"j": 8,
"k": 9,
},
"foo": Object {
"e": 4,
"f": 5,
"g": 6,
"h": Object {
"generated": false,
"id": "bar",
"type": "id",
"typename": "Bar",
},
},
}
`;

exports[`Cache writeFragment will write some deeply nested data into the store at any id (3/3) 6`] = `
Object {
"bar": Object {
"i": 10,
Expand Down
Loading

0 comments on commit 525d9ec

Please sign in to comment.