[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? https://github.com/apollographql/datasource-rest |
trevor-scheer
left a comment
There was a problem hiding this comment.
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.
c73b57f to
6768111
Compare
Fixes #6603
By default,
RESTDataSourcecaches 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 totrueto 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