cacheControl on Query type

Hi,

I was wondering, is there a way to put @cacheControl(maxAge: 60) on the Query type?

I know we can put it on individual fields but I don’t see an option to do it on the type Query.

The reasoning was to cache every root query without having to go through each one and put @cacheControl on it.

Thanks.

UPDATE

I found a solution, instead I used the defaultMaxAge plugin and it solved my issue.

1 Like

Thank you for sharing the update to your question. Yes that would be my reccomended solution as well: Server-Side Caching - Apollo GraphQL Docs

But also you could always build your own directive to do custom features too. The static directive is quite simple in it’s code so you could make one yourself that could include the QUERY location: Server-Side Caching - Apollo GraphQL Docs

1 Like