-
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
Feature Request: expose cache keys in resolvers/directives #3228
Comments
That does seem like it would be a useful bit of data to expose. I haven't been personally using this feature (or working in the Apollo Server codebase at all) very heavily since my initial implementation, so definitely curious what @abernix and others who are more involved think. |
Hello, any updates about this feature ? I've also faced with cache invalidation issue, could you help me, please ? |
@BondDimy I think the easiest way is to implement your own cache plugin that exposes the cache key, record the key in a directive, and invalidate them in another directive when needed. More discussions here: #2437 (comment) |
@guoliu Thanks too much for your reply, yep I thought about custom plugin, currently working on it |
Does anyone have examples of plugins that do this? |
@nelsonpecora you can checkout this repo: https://github.com/thematters/apollo-response-cache |
@guoliu ooh, this looks like exactly what we need, thanks! |
I hope the other cache plugin helps! One note is that the concept of "the cache key" for the current full response cache plugin doesn't quite make sense: when using the Since AS v3.10.0, the response cache plugin has a generateCacheKey option which takes in GraphQLRequestContext. So you could pass this option and give it the side effect of recording the generated cache key on your Because it seems like there are multiple ways to achieve this goal (and the goal itself isn't entirely well-defined) I'm going to close this issue. Sorry for the delay! |
I haven't find any current ways of doing this, but it should be extremely helpful for folks who need more control on caches like us.
We are implementing a cache invalidation mechanism, where we keep a mapping between object global id and the list of cache keys associate with it, then invalidate that list when needed.
However, there's currently no easy way of getting the cache key in resolvers or directives. Looks like the cache key can be add to request context after this line, so everything downstream can access it if needed.
Do you think that's a reasonable feature, and are there any unexpected side effects of adding keys to context?
The text was updated successfully, but these errors were encountered: