-
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
Fix cache policy calculation #2197
Fix cache policy calculation #2197
Conversation
Awesome - I am working on some cache related features this week and had noticed the same concern. Will probably merge Monday! |
@@ -156,7 +156,7 @@ export class CacheControlExtension<TContext = any> | |||
let scope: CacheScope = CacheScope.Public; | |||
|
|||
for (const hint of this.hints.values()) { | |||
if (hint.maxAge) { | |||
if (hint.maxAge !== undefined) { | |||
lowestMaxAge = lowestMaxAge |
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.
Should the check here (before the ?
) also be against undefined
?
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.
Yes, you are right. Didn't check that case in the tests. 😕
Just fixed it and adjusted the test.
Thanks! |
This is consistent with the old engineproxy interpretation of cache hints. We special-case scalar fields to inherit their parent field's hints for simplicity (so you don't have to hint every scalar field in a hinted object), but when the parent field is non-root that inherited hint gets defaultMaxAge applied to it. When the parent field is the root, that inherited hint doesn't get defaultMaxAge applied because we don't run willResolveField for the root query. Includes a CHANGELOG update for #2197.
This is consistent with the old engineproxy interpretation of cache hints. We special-case scalar fields to inherit their parent field's hints for simplicity (so you don't have to hint every scalar field in a hinted object), but when the parent field is non-root that inherited hint gets defaultMaxAge applied to it. When the parent field is the root, that inherited hint doesn't get defaultMaxAge applied because we don't run willResolveField for the root query. Includes a CHANGELOG update for #2197.
This is consistent with the old engineproxy interpretation of cache hints. We special-case scalar fields to inherit their parent field's hints for simplicity (so you don't have to hint every scalar field in a hinted object), but when the parent field is non-root that inherited hint gets defaultMaxAge applied to it. When the parent field is the root, that inherited hint doesn't get defaultMaxAge applied because we don't run willResolveField for the root query. Includes a CHANGELOG update for #2197.
…2210) This is consistent with the old engineproxy interpretation of cache hints. We special-case scalar fields to inherit their parent field's hints for simplicity (so you don't have to hint every scalar field in a hinted object), but when the parent field is non-root that inherited hint gets defaultMaxAge applied to it. When the parent field is the root, that inherited hint doesn't get defaultMaxAge applied because we don't run willResolveField for the root query. Includes a CHANGELOG update for #2197.
Fixes apollographql/apollo-cache-control#11
TODO: