-
Notifications
You must be signed in to change notification settings - Fork 1.5k
feat(Query): Add cacheControl directive that adds headers in the response #6799
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
Conversation
| @@ -343,6 +344,13 @@ func (o *operation) Mutations() (ms []Mutation) { | |||
| return | |||
| } | |||
|
|
|||
| func (o *operation) CacheControl() string { | |||
| if o.op.Directives.ForName(cacheControlDirective) == nil { | |||
| return "" | |||
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.
private,no-cache would work instead of empty string
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.
adding header only if the directive is there, otherwise no header.
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.
Reviewed 3 of 5 files at r1, 1 of 2 files at r2, 3 of 46 files at r3.
Reviewable status: 7 of 52 files reviewed, 3 unresolved discussions (waiting on @abhimanyusinghgaur, @anurags92, @gja, @MichaelJCompton, and @pawanrawal)
Motivation
This PR adds support for users to enable browser/CDN side caching for their queries. Users can specify
@cacheControl(maxAge: 15)at the top of their query. This would result in the response being returned with appropriate HTTP headers so that browsers and CDNs can cache the response.More details can be read on discuss.
http headers returned:
This PR fixes: GRAPHQL-722
Components affected by this PR
Does this PR break backwards compatibility?
No
Testing
Added following tests in:
[WIP]
Fixes
Fixes GRAPHQL-722
This change is