-
Notifications
You must be signed in to change notification settings - Fork 111
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
GraphQL 4 query response weirdness with fresh fluent install #768
Comments
At the moment the fluent middleware doesn't know how to pull locale from graphql queries. I typically bake all of my queries with a $locale parameter, and manually set the locale in my resolver. public function initialiseLocale($locale): Locale
{
// Get locale by region / langauge
$localeObject = Locale::getCached()->find('Locale', $locale);
if (!$localeObject) {
throw new HTTPResponse_Exception("No locale {$locale} exists");
}
// Initialise state
FluentState::singleton()
->setIsFrontend(true)
->setIsDomainMode(false)
->setLocale($localeObject->Locale);
i18n::set_locale($localeObject->Locale);
return $localeObject;
} |
By the way, if you wanted to do this globally for all graphql queries, you could override DetectLocaleMiddleware::getLocale, and manually extract the "locale" graphql parameter there. You'd just need to make sure you were capturing graphql requests explicitly. |
Hi @tractorcow We have not even looked at the problem of how to handle locales in the graphql queries yet, so thanks for the tipps, this will come in very handy. What we observed though, is that the response to the query cited above is totally not as expected as soon as fluent was installed. As long as the existing pages had not been migrated to the default locale, the query would return all sorts of pages which DO NOT match the filter ... is this an expected behavior ? |
It's not really expected; Perhaps there's something that still needs to be flushed / migrated? Have you checked that you've marked a locale as default? If you've only just installed fluent, you would need to setup a list of locales with at least one value set as the global default. Do you have a domain setup, but did not specify a default locale for that domain? |
I've leave the ticket open since there still seems to be some odd behaviour about the default locale being assigned. |
We had not setup anything ... just added the fluent package to an existing site ... it did not have any ill effects ... except for the strange results from the query above ... we also tried what happens when we added a default locale ... the strange results kept coming ... once we ran the |
We have added fluent to an existing site, without migrating pages to a default locale yet ... the presence of fluent does not seem to negatively affect site, except for one thing. The query below returns a huge amount of pages, seemingly ignoring the filter condition.
If I pick a parentID other than 0, all is well again.
Once we migrated the existing pages to the default language the behavior reverted to returning only pages matching the filter.
I have not tried this on a fresh install, but we are using all the latest ss4, graphql4 and fluent 5 bits. Maybe this problem does ring a bell with someone who knows about fluent GraphQL interaction.
The text was updated successfully, but these errors were encountered: