Expose the Graphql queries tags in an Event #18442
-
|
Hello! We have a lot of headless Craft websites with a Nuxt frontend in front of the GraphQL API. We'd like to have more control over the GraphQL query cache. Ideally, we would take some inspiration from the way WPGraphql-Smart-Cache works on the WordPress side and expose all the cache tags in a response header. This way, we could have Varnish or another caching layer use these tags to manually handle our caching strategy. There is the EVENT_INVALIDATE_CACHES event that allows us to get all the tags that will be invalidated, but I don't think there is an event that triggers when the cache is created. Would it make sense to update the EVENT_AFTER_EXECUTE_GQL_QUERY event so it returns the TagDependency array? This way, we can add this in a header or do some custom things with the list. Thanks ! Arthur |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
Easy enough! We just tagged Craft 5.9.11 which includes new Note that they will only be set when a non-cached query is executed, however the event will fire even if the query was already cached. |
Beta Was this translation helpful? Give feedback.
Easy enough! We just tagged Craft 5.9.11 which includes new
$cacheTagsand$cacheDurationproperties added toExecuteGqlQueryEvent. (9c6b6f1)Note that they will only be set when a non-cached query is executed, however the event will fire even if the query was already cached.