Cache options on graphql SDL

Hi All,

Just wondering if anyone has gotten cache control headers working with graphql with RW?

I’ve looked into using the @cacheControl directive, but get an error when it tries to merge schema.

Note that I’m talking about server side cache control headers: and not caching in Apollo client.

Don’t need a solution necessarily, some tips on how to add the directive (and if its possible) can set me off in the right direction.


Wondering if this is going to help (or hinder)?

I actually had this working on the CV19 site that was launched when we announced Redwood:

I did it for the entire site, but I think I did play around with modifying the individual fields.

Thanks both! Yeah, I can see that its possible to apply to “all queries”, but I think it would be useful to be able to control at at a query level, especially because Apollo already supports this.

So the more specific question is, how can we add the @cacheControl(maxAge: xx) directive to our graphql server, so it knows how to parse the schema.

I don’t really know enough about apollo/graphql just yet, but I’m guessing RW uses graphql-tools underneath to parse the schema?

Important note on compatibility: Setting cache hints is currently incompatible with the graphql-tools implementation of schema stitching, because cache hints are not appropriately communicated from one service to the other.

Starting points:

We’re actually using:

Which is now deprecated! Whoops! They’ve suggested we upgrade to GraphQL Tools: