-
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
feat: allow per-request caching in RESTDataSource #5015
feat: allow per-request caching in RESTDataSource #5015
Conversation
implements `protected shouldCacheRequest` fixes #5007
Just want to note that reviewing this is definitely on my radar. That said, new features often require more care in review than bug fixes, and while I'm the lead Apollo Server maintainer, I am not super familiar with the internals of RESTDataSource, so reviewing this is blocked on finding time to understand the package more deeply. |
Thanks for the reply! We've been trying to leverage more of the advanced caching and deduplication features, and doing some code spelunking lately in these files. If you have any questions about our use case or how we see this feature helping, lmk. |
Would love to have this merged, I was just about to work on making a PR for it, so I am glad that I checked first. |
I don't believe anyone currently on the Apollo Server team has come up to speed enough yet on Perhaps |
@glasser My use case for example is extending it to also cache posts that are graphql calls instead of only caching gets. |
Yes, but it seems fraught to name a new entry point "should cache request" without a thorough understanding of the two layers of caching in the software and whether it's an appropriate name for whichever level it affects. |
I am also looking for this pull request to be merged. This allows us to extend the current cacheing mechanism and allows us to write custom logic around cacheing. Any way I can help get this merged in @glasser ? |
At the moment, your best bet would be to find a Node caching HTTP client with a maintainer.
|
This package has moved to a new repository. I'm closing this PR, but we do plan to spend some time working on RESTDataSource soon; I opened apollographql/datasource-rest#64 to remind us to look at this PR. Sorry for the delay! |
implements
protected shouldCacheRequest
fixes apollographql/datasource-rest#73
protected shouldCacheRequest(request: Request): boolean
toRESTDataSource
, allowing users to configure which requests are held in the http cache. This is useful for query-likePOST
requests, for example, or if users want to prevent certainGET
requests from ever being cached.Usage
Users extending from
RESTDataSource
may override the default implementation ofshouldCacheRequest
: