Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update field cache to allow it to be used wihtout the query_name #6

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

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
Member

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