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

Two unrelated small cache improvements #7241

Merged
merged 1 commit into from Dec 12, 2022
Merged

Conversation

glasser
Copy link
Member

@glasser glasser commented Dec 10, 2022

  • Explicitly allow people to pass cache: 'bounded'. Non-TS users upgrading from the recommended AS3.9+ configuration could do this by accident. Fixes Allow cache: "bounded" or fail quickly if it is passed #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 fqc prefix is added and there's no way to disable it #6742.

- 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.
@netlify
Copy link

netlify bot commented Dec 10, 2022

Deploy Preview for apollo-server-docs ready!

Name Link
🔨 Latest commit fa9fdd4
🔍 Latest deploy log https://app.netlify.com/sites/apollo-server-docs/deploys/639511539cefee000844fc96
😎 Deploy Preview https://deploy-preview-7241--apollo-server-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@glasser
Copy link
Member Author

glasser commented Dec 10, 2022

I put this in one PR because they touched similar code. A test would be nice but eh, we don't have any tests of passing cache at all...

@codesandbox-ci
Copy link

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit fa9fdd4:

Sandbox Source
Apollo Server Typescript Configuration
Apollo Server Configuration

Copy link
Member

@trevor-scheer trevor-scheer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we leave the deps as-is all the packages besides server? I think those deps continue to be compatible and they're careted.

@@ -214,6 +220,19 @@ export class ApolloServer<in out TContext extends BaseContext = BaseContext> {

const isDev = nodeEnv !== 'production';

if (
config.cache &&
config.cache !== 'bounded' &&
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we log / warn when this is set? It'd be nice to re-remove this for good in v5

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You think so? I feel like it's not a huge deal and not worth bugging folks about (and if we have a very short migration guide for v5 then it's fine to remove it then without an explicit deprecation period).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I don't feel too strongly about it, I guess the nice thing about the warning is it's simple and actionable: "you have a line of code that you can delete". I'm ok with leaving it though.

@glasser
Copy link
Member Author

glasser commented Dec 12, 2022

For the cache plugin we definitely want the upgrade. And integration test doesn't really matter either way. I guess the only one where not upgrading makes sense is gateway-interface... but I do kinda like trying to keep deps consistent to avoid accidental double installs?

Would like your thoughts on both these questions before I merge/release @trevor-scheer.

@trevor-scheer
Copy link
Member

Nbd to upgrade them, go ahead and keep as is 👍

@glasser glasser merged commit d7e9b97 into main Dec 12, 2022
@glasser glasser deleted the glasser/cache-improvements branch December 12, 2022 18:40
@github-actions github-actions bot mentioned this pull request Dec 12, 2022
glasser pushed a commit that referenced this pull request Dec 12, 2022
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## @apollo/server-plugin-response-cache@4.1.0

### Minor Changes

- [#7241](#7241)
[`d7e9b9759`](d7e9b97)
Thanks [@glasser](https://github.com/glasser)! - 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.

## @apollo/server@4.3.0

### Minor Changes

- [#7241](#7241)
[`d7e9b9759`](d7e9b97)
Thanks [@glasser](https://github.com/glasser)! - 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.

### Patch Changes

- [#7232](#7232)
[`3a4823e0d`](3a4823e)
Thanks [@glasser](https://github.com/glasser)! - Refactor the
implementation of `ApolloServerPluginDrainHttpServer`'s grace period.
This is intended to be a no-op.

- [#7229](#7229)
[`d057e2ffc`](d057e2f)
Thanks [@dnalborczyk](https://github.com/dnalborczyk)! - Improve
compatibility with Cloudflare workers by avoiding the use of the Node
`util` package. This change is intended to be a no-op.

- [#7228](#7228)
[`f97e55304`](f97e553)
Thanks [@dnalborczyk](https://github.com/dnalborczyk)! - Improve
compatibility with Cloudflare workers by avoiding the use of the Node
`url` package. This change is intended to be a no-op.

- [#7241](#7241)
[`d7e9b9759`](d7e9b97)
Thanks [@glasser](https://github.com/glasser)! - 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).

## @apollo/server-integration-testsuite@4.3.0

### Patch Changes

- [#7228](#7228)
[`f97e55304`](f97e553)
Thanks [@dnalborczyk](https://github.com/dnalborczyk)! - Improve
compatibility with Cloudflare workers by avoiding the use of the Node
`url` package. This change is intended to be a no-op.

- Updated dependencies
\[[`3a4823e0d`](3a4823e),
[`d057e2ffc`](d057e2f),
[`f97e55304`](f97e553),
[`d7e9b9759`](d7e9b97),
[`d7e9b9759`](d7e9b97)]:
    -   @apollo/server@4.3.0

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow cache: "bounded" or fail quickly if it is passed fqc prefix is added and there's no way to disable it
2 participants