Response Caching through @cacheControl directive
Response caching is a feature that allows you to cache the responses of your GraphQL Mesh Gateway via @cacheControl directive
Response caching is a technique for reducing server load by caching GraphQL query operation results. For incoming GraphQL Query operations with the same variable values, the same response is returned from a cache instead of executed again.
To set static cache hints within subgraphs, the @cacheControl directive and CacheControlScope
enum definitions must be included in the subgraph schema:
Then in the subgraph schema, you can use the @cacheControl directive to set cache hints on fields, types, and interfaces:
Time-to-live (TTL)
Enforce session based caching
In some cases, a type or a field should only be cached if their is a session. For this, you can use
the scope to indicate that the cache should only be used if a session is present.
Any query containing a type or a field with the scope PRIVATE will only be cached if a session is
present.