wp-graphql-cache
wp-graphql-cache copied to clipboard
Update field cache to allow it to be used wihtout the query_name
Update field caching to work across multiple queries.
This PR allows a field cache to be configured across multiple / all queries. When the query_name
parameter is omitted, a field cache will be global and not tied to a specific query at all.
This is useful for caching fields which are included across multiple queries. An example from a project I am working on is the menus, which are included in every query we do. I can configure a field cache like so and have it computed on once globally for all of our queries.
E.g.
CacheManager::register_graphql_field_cache(
array(
'zone' => 'menus',
'field_name' => 'headerMenus',
'expire' => 600, // seconds.
)
);
This is still compatible with fields configured with a query_name
and will function exactly as it does currently.
Doesn't 'query_name' => '*'
already enable this?