wp-graphql / wp-graphql-smart-cache

Smart Caching & Cache Invalidation for WPGraphQL
61 stars 14 forks source link

As a developer, I would like to be able to filter the GraphQL Query Cache Key #93

Open jasonbahl opened 2 years ago

jasonbahl commented 2 years ago

When a GraphQL Query is cached, the key is generated from information such as:

It would be good to be able to filter the cache key to support additional fields, such as extensions, that can be included in GraphQL requests.

One use case I've thought about, is internationalization.

"extensions": {
  "locale": "ES_MX"
}

I would like my query to execute with Spanish - Mexico translations.

It would be good to allow plugin authors (WPGraphQL for Polylang, possibly, in this case) to be able to filter the cache key to account for these other inputs.

jasonbahl commented 2 years ago

I believe we should be able to apply a filter to the $parts here: https://github.com/wp-graphql/wp-graphql-smart-cache/blob/main/src/Cache/Query.php#L58-L63