feature: support cacheControl static hints
Describe the Feature Request
Recently, Apollo released federation-jvm:0.8.0 which added support for the CacheControl schema directive, used for static cache hints.
More details on this can be found in their release notes and public documentation, as well as these two dgs-framework discussions #821 and #498
Describe Preferred Solution
A suggestion was made in https://github.com/Netflix/dgs-framework/discussions/821#discussioncomment-1956973 to set the HTTP Cache Headers based on the most-restricted cache condition as calculated by the federation-jvm library
Describe Alternatives
Thanks, we will look into updating the version of federation-jvm so you can leverage this functionality. I believe you should get it for free once we release the framework with the updated version.
Correction: We will need to do some work to integrate with this feature, won't be readily usable even when we do update.
That was more work then expected 😥
@srinivasankavitha is @cacheControl implemented in dgs? i have <dgs.version>8.6.0</dgs.version> <federation-jvm.version>4.4.1</federation-jvm.version> <graphql-java.version>22.0</graphql-java.version>
I have defined like this in my schema file below:
directive @cacheControl( maxAge: Int scope: CacheControlScope inheritMaxAge: Boolean ) on FIELD_DEFINITION | OBJECT | INTERFACE | UNION
enum CacheControlScope { PUBLIC PRIVATE }
type Query{ some_query(): ReturnType! @cacheControl(maxAge: 600) }
no while calling the query from any client or postman i am unable to get cache-control in the response header, due to which the apollo supergraph is unable to perform the caching flow.
let me know how can i set cache-control in the response headers properly
We don't have any explicit support for this in the DGS Framework, and don't have this prioritized yet for the near term. We will post an update when we have more information on timelines.