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

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

Open
jasonbahl opened this issue Jan 25, 2022 · 1 comment
Assignees
Labels
type: enhancement Improvements to existing functionality
Milestone

Comments

@jasonbahl
Copy link
Collaborator

jasonbahl commented Jan 25, 2022

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

  • normalized query string
  • user executing the query
  • variables

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.

  • if I were to pass an extension, such as (not currently implemented):
"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 jasonbahl added the type: enhancement Improvements to existing functionality label Jan 25, 2022
@jasonbahl jasonbahl added this to the Query Caching milestone Jan 26, 2022
@jasonbahl
Copy link
Collaborator Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement Improvements to existing functionality
Projects
None yet
Development

No branches or pull requests

2 participants