wp-graphql-cache
wp-graphql-cache copied to clipboard
Caching queries with variables
Thanks for this plugin!
I was wondering how caching a named query with query variables works. Let's say I have a paginated query using the after
filter.
query MyPosts( $after: String ) {
posts(after: $after, first: 10) {
edges {
node {
title
}
}
}
}
Would caching query MyPosts
(see below) automatically handle different versions of the query based on the passed variables? Or does it ignore variables all together?
use WPGraphQL\Extensions\Cache\CacheManager;
CacheManager::register_graphql_query_cache([
'query_name' => 'MyPosts',
'expire' => 120,
]);
seems like would ignore them? I think this would be a very useful feature