-
Notifications
You must be signed in to change notification settings - Fork 2k
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
[apollo-datasource-rest] Add option to disable GET cache #6650
[apollo-datasource-rest] Add option to disable GET cache #6650
Conversation
🦋 Changeset detectedLatest commit: 7bc65a7 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
✅ Deploy Preview for apollo-server-docs canceled.Built without sensitive environment variables
|
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 0134a13:
|
1850f12
to
8562674
Compare
Part of the issue was also that this feature was undocumented so I have added some basic info about the |
cc @Jaxolotl |
cc @trevor-scheer and @glasser. I can port my changes over to the new package, but this change is still relevant to anyone using ASv3 today or whoever will in the future with respect to the doc changes. Can I get a review for this one? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please add why someone would want this behavior to the PR description? Totally fine if it's the same blurb that I asked to be added to the docs, just want people to understand why they'd disable it.
We can delete the changeset, and add an entry to CHANGELOG
- sorry, we had the bot enabled for v4 development (glasser's since disabled it) which made it confusing for dev on main since we're not using it for v3 things.
packages/apollo-datasource-rest/src/__tests__/RESTDataSource.test.ts
Outdated
Show resolved
Hide resolved
packages/apollo-datasource-rest/src/__tests__/RESTDataSource.test.ts
Outdated
Show resolved
Hide resolved
c73b57f
to
6768111
Compare
Fixes #6603
By default,
RESTDataSource
caches all outgoing GET requests in a separate memoized cache from the regular response cache. It makes the assumption that all responses from HTTP GET calls are cacheable by their URL.If a request is made with the same cache key (URL by default) but with an HTTP method other than GET, the cached request is then cleared.
This change adds a new class property
requestCacheEnabled
(which defaults totrue
to match current behavior) which allows users to disable the cache. You might want to do this if your API is not actually cacheable or your data changes over time.Separately it documents this feature exists and adds more info about how to set a TTL for the entire HTTP cache