Skip to content

Commit d7e9b97

Browse files
authored
Two unrelated small cache improvements (#7241)
- Explicitly allow people to pass `cache: 'bounded'`. Non-TS users upgrading from the recommended AS3.9+ configuration could do this by accident. Fixes #7240. - Upgrade `@apollo/utils.keyvaluecache` so that the new `PrefixingKeyValueCache.cacheDangerouslyDoesNotNeedPrefixesForIsolation` feature lets you disable prefixing for the APQ and full response caches. Throw if you try to pass such a cache to `ApolloServer` itself because that cache is designed to be shared across features. Migrate off of PrefixingKeyValueCache for `documentStore` so that its prefixing can't be disabled. Fixes #6742.
1 parent f0fcdac commit d7e9b97

File tree

12 files changed

+191
-88
lines changed

12 files changed

+191
-88
lines changed

.changeset/fifty-eyes-chew.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@apollo/server-plugin-response-cache': minor
3+
---
4+
5+
If the cache you provide to the `cache` option is created with `PrefixingKeyValueCache.cacheDangerouslyDoesNotNeedPrefixesForIsolation` (new in `@apollo/utils.keyvaluecache@2.1.0`), the `fqc:` prefix will not be added to cache keys.

.changeset/selfish-buckets-mate.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@apollo/server': minor
3+
---
4+
5+
If the cache you provide to the `persistedQueries.cache` option is created with `PrefixingKeyValueCache.cacheDangerouslyDoesNotNeedPrefixesForIsolation` (new in `@apollo/utils.keyvaluecache@2.1.0`), the `apq:` prefix will not be added to cache keys. Providing such a cache to `new ApolloServer()` throws an error.

.changeset/sour-kiwis-eat.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@apollo/server': patch
3+
---
4+
5+
For ease of upgrade from the recommended configuration of Apollo Server v3.9+, you can now pass `new ApolloServer({ cache: 'bounded' })`, which is equivalent to not providing the `cache` option (as a bounded cache is now the default in AS4).

docs/source/api/apollo-server.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ Controls whether to allow [Batching Queries](../workflow/requests/#batching) in
353353

354354
A [`KeyValueCache`](https://www.npmjs.com/package/@apollo/utils.keyvaluecache) which Apollo Server uses for several features, including APQs and full response caching. This cache is also available to Apollo Server's plugins.
355355

356-
The default cache is an [`InMemoryLRUCache`](https://www.npmjs.com/package/@apollo/utils.keyvaluecache) with a default size of roughly 30MiB.
356+
The default cache is an [`InMemoryLRUCache`](https://www.npmjs.com/package/@apollo/utils.keyvaluecache) with a default size of roughly 30MiB. (For backwards-compatibility with Apollo Server 3, specifying `cache: 'bounded'` also selects this default bounded cache.)
357357

358358
To learn more about configuring Apollo Server's cache, see [Configuring cache backends](../performance/cache-backends).
359359

package-lock.json

Lines changed: 136 additions & 71 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/gateway-interface/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"dependencies": {
2121
"@apollo/utils.fetcher": "^2.0.0",
2222
"@apollo/utils.logger": "^2.0.0",
23-
"@apollo/utils.keyvaluecache": "^2.0.1",
23+
"@apollo/utils.keyvaluecache": "^2.1.0",
2424
"@apollo/usage-reporting-protobuf": "^4.0.0"
2525
},
2626
"peerDependencies": {

packages/integration-testsuite/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"@apollo/client": "^3.6.9",
3131
"@apollo/server": "4.2.2",
3232
"@apollo/server-plugin-landing-page-graphql-playground": "^4.0.0",
33-
"@apollo/utils.keyvaluecache": "^2.0.1",
33+
"@apollo/utils.keyvaluecache": "^2.1.0",
3434
"@apollo/utils.createhash": "^2.0.0",
3535
"@apollo/usage-reporting-protobuf": "^4.0.0",
3636
"@josephg/resolvable": "^1.0.1",

packages/plugin-response-cache/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
},
3131
"dependencies": {
3232
"@apollo/utils.createhash": "^2.0.0",
33-
"@apollo/utils.keyvaluecache": "^2.0.1"
33+
"@apollo/utils.keyvaluecache": "^2.1.0"
3434
},
3535
"peerDependencies": {
3636
"@apollo/server": "^4.0.1",

0 commit comments

Comments
 (0)