Skip to content

Conversation

@zacscott
Copy link
Contributor

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.

@esamattis
Copy link
Contributor

Doesn't 'query_name' => '*' already enable this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants