dgs-framework icon indicating copy to clipboard operation
dgs-framework copied to clipboard

feature: support cacheControl static hints

Open setchy opened this issue 3 years ago • 4 comments

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

setchy avatar Mar 11 '22 14:03 setchy

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.

srinivasankavitha avatar Mar 14 '22 01:03 srinivasankavitha

That was more work then expected 😥

jord1e avatar Apr 09 '22 15:04 jord1e

@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

yamalameyooooo avatar May 13 '24 08:05 yamalameyooooo

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.

srinivasankavitha avatar May 13 '24 17:05 srinivasankavitha