Skip to content

Commit

Permalink
Merge pull request #4251 from apollographql/issue-4210-avoid-caching-…
Browse files Browse the repository at this point in the history
…optimistic-results

Avoid using DepTrackingCache for optimistic reads.
  • Loading branch information
benjamn committed Dec 19, 2018
2 parents 7d0ed16 + f25c0dd commit 2cce067
Show file tree
Hide file tree
Showing 9 changed files with 508 additions and 311 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,21 @@
`@client` directives. <br/>
[@justinmakaila](https://github.com/justinmakaila) in [#3482](https://github.com/apollographql/apollo-client/pull/3482)

### Apollo Cache In-Memory (1.3.12)

- Avoid using `DepTrackingCache` for optimistic reads.
[PR #4521](https://github.com/apollographql/apollo-client/pull/4251)

- When creating an `InMemoryCache` object, it's now possible to disable the
result caching behavior introduced in [#3394](https://github.com/apollographql/apollo-client/pull/3394),
either for diagnostic purposes or because the benefit of caching repeated
reads is not worth the extra memory usage in your application:
```ts
new InMemoryCache({
resultCaching: false
})
```
Part of [PR #4521](https://github.com/apollographql/apollo-client/pull/4251).

## Apollo Client (2.4.7)

Expand Down
6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,10 @@
},
"lint-staged": {
"*.ts*": [
"prettier --ignore-path \"./config/prettierignore\" --trailing-comma all --single-quote --write",
"git add"
"prettier --ignore-path \"./config/prettierignore\" --trailing-comma all --single-quote --write"
],
"*.js*": [
"prettier --ignore-path \"./config/prettierignore\" --trailing-comma all --single-quote --write",
"git add"
"prettier --ignore-path \"./config/prettierignore\" --trailing-comma all --single-quote --write"
]
},
"pre-commit": "lint-staged",
Expand Down
53 changes: 17 additions & 36 deletions packages/apollo-cache-inmemory/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/apollo-cache-inmemory/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "apollo-cache-inmemory",
"version": "1.3.11",
"version": "1.3.12-beta.1",
"description": "Core abstract of Caching layer for Apollo Client",
"author": "James Baxley <james@meteor.com>",
"contributors": [
Expand Down Expand Up @@ -44,7 +44,7 @@
"dependencies": {
"apollo-cache": "file:../apollo-cache",
"apollo-utilities": "file:../apollo-utilities",
"optimism": "^0.6.6"
"optimism": "^0.6.8"
},
"peerDependencies": {
"graphql": "0.11.7 || ^0.12.0 || ^0.13.0 || ^14.0.0"
Expand Down
146 changes: 128 additions & 18 deletions packages/apollo-cache-inmemory/src/__tests__/__snapshots__/cache.ts.snap
Original file line number Diff line number Diff line change
@@ -1,8 +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`
] = `
exports[`Cache writeFragment will write some deeply nested data into the store at any id (1/2) 1`] = `
Object {
"bar": Object {
"i": 7,
Expand All @@ -19,9 +17,7 @@ Object {
}
`;

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

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

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

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

exports[
`Cache writeFragment will write some deeply nested data into the store at any id 6`
] = `
exports[`Cache writeFragment will write some deeply nested data into the store at any id (1/2) 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 (2/2) 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 (2/2) 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 (2/2) 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 (2/2) 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 (2/2) 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 (2/2) 6`] = `
Object {
"bar": Object {
"i": 10,
Expand Down
Loading

0 comments on commit 2cce067

Please sign in to comment.