You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We're building a multilingual site, and every query is getting a default variable with the current language site like so;
/**
* Sets the default variables for all requests.
*/
const defaultVariables = definePlugin(({ operation }) => {
// Only set the site if it hasn't been set yet.
if (operation.variables && !('site' in operation.variables)) {
operation.variables.site = nuxt?.$i18n?.localeProperties?.value?.craftSiteHandle;
}
// // Only set the uri if it hasn't been set yet.
if (operation.variables && !('uri' in operation.variables)) {
operation.variables.uri = plainUri;
}
});
This is causing a problem however with the cache plugin from the defaultPlugins list, as the cache key is getting set before the plugins run (?) at any rate, when the language changes, it uses cached data for a different set of query variables now.
I re-generate the key after setting the variables in the plugin above now, which feels like a bit of a workaround
operation.key = getQueryKey(operation);
This successfully fixed the caching issue for me.
I would suggest the key would get (re)calculated in the dedup/cache plugins when they run?
The text was updated successfully, but these errors were encountered:
We're building a multilingual site, and every query is getting a default variable with the current language site like so;
This is causing a problem however with the
cache
plugin from thedefaultPlugins
list, as the cache key is getting set before the plugins run (?) at any rate, when the language changes, it uses cached data for a different set of query variables now.I re-generate the key after setting the variables in the plugin above now, which feels like a bit of a workaround
operation.key = getQueryKey(operation);
This successfully fixed the caching issue for me.
I would suggest the key would get (re)calculated in the dedup/cache plugins when they run?
The text was updated successfully, but these errors were encountered: