-
Notifications
You must be signed in to change notification settings - Fork 575
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: add served from response cache symbol to response cache #3164
Conversation
🦋 Changeset detectedLatest commit: ae0790a The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
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 |
Apollo Federation Subgraph Compatibility Results
Learn more: |
✅ Benchmark Results
|
💻 Website PreviewThe latest changes are available as preview in: https://b5a3b9eb.graphql-yoga.pages.dev |
655e729
to
ae0790a
Compare
@@ -170,10 +170,14 @@ export function useResponseCache(options: UseResponseCacheParameter): Plugin { | |||
if (enabled(request)) { | |||
const cachedResponse = await cache.get(operationId); | |||
if (cachedResponse) { | |||
const responseWithSymbol = { | |||
...cachedResponse, | |||
[Symbol.for('servedFromResponseCache')]: true, |
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.
So finaly you don't expose the entire metadata object ?
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.
it would be { hit: true }
always in this scenario anyways, we can change it to an object later on if there is more information to store.
Add
servedFromResponseCache
symbol property to responses served from the response cache in orderto allow other plugins to determine, whether a response was served from the cache and apply custom
logic based on that.
This is required for solving graphql-hive/console#3807