Skip to content
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

Merged
merged 2 commits into from Jan 22, 2019
Merged

Fix cache policy calculation #2197

merged 2 commits into from Jan 22, 2019

Conversation

fabsrc
Copy link
Contributor

@fabsrc fabsrc commented Jan 18, 2019

Fixes apollographql/apollo-cache-control#11

TODO:

  • Update CHANGELOG.md with your change (include reference to issue & this PR)
  • Make sure all of the significant new logic is covered by tests
  • Rebase your changes on master so that they can be merged easily
  • Make sure all tests and linter rules pass

@glasser
Copy link
Member

glasser commented Jan 19, 2019

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
Copy link
Member

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?

Copy link
Contributor Author

@fabsrc fabsrc Jan 22, 2019

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.

@glasser glasser merged commit 06e4907 into apollographql:master Jan 22, 2019
@glasser
Copy link
Member

glasser commented Jan 22, 2019

Thanks!

glasser added a commit that referenced this pull request Jan 22, 2019
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.
glasser added a commit that referenced this pull request Jan 22, 2019
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.
glasser added a commit that referenced this pull request Jan 24, 2019
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.
@abernix abernix added this to the Release 2.3.1 milestone Jan 24, 2019
abernix pushed a commit that referenced this pull request Jan 25, 2019
…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.
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants