Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Where clause in GraphQL query does not work on fallbackLocale #6477

Closed
STR1234 opened this issue May 23, 2024 · 1 comment
Closed

Where clause in GraphQL query does not work on fallbackLocale #6477

STR1234 opened this issue May 23, 2024 · 1 comment

Comments

@STR1234
Copy link

STR1234 commented May 23, 2024

Link to reproduction

No response

Describe the Bug

When having a GraphQL Query that has a fallbackLocale specified and using a where clause to filter for specific checkbox value (in this case) the where selector does not work properly on the specified fallbackLocale.

		fallbackLocale: en_DE
		limit: 500
		where: { showInOverview: { equals: true } }

Here I fallback to a locale where at least one document has the showInOverview value set to true. When querying directly for the locale en_DE this does indeed deliver the proper results.
When querying for a locale that does not yet have any data and falling back to en_DE the where operation has the consequence that no documents are found. When removing the where clause the expected data from the en_DE fallback locale is delivered.

To Reproduce

  1. Have a document with a field (textfield, checkbox or something that makes for an easy where selection) that has localized set to true and another field (like a text field) also with localized set to true just for content.
  2. Have at least two locales configured and for one of them the document has data (fields are filled out), for the other it does not.
  3. Specify the GraphQL query to fallback to the locale where data was entered.
  4. Query for the document with the locale that does not have data, also specifying that one of the documents fields needs to have a certain value with the where clause (easiest would be a checkbox boolean value like in my case).
  5. Even though the document in the fallback locale contains the appropriate value no documents are returned.

After further investigation: (edited the reproduction steps as well)
I found that for a slug text field that I have in the document it works properly but with another title text field it does not work.

The only difference between the fields:
The title is required and localized. The slug is neither.
The showInOverview field is also localized and required. This might have something to do with the fact that the field I select for in the query is localized 🤔 (I would suspect that rather than the required prop)

Payload Version

2.13.0

Adapters and Plugins

db-mongodb, bundler-webpack, plugin-cloud-storage, richtext-lexical, translator-plugin

@STR1234 STR1234 added the status: needs-triage Possible bug which hasn't been reproduced yet label May 23, 2024
@jmikrut
Copy link
Member

jmikrut commented Jun 10, 2024

Hey @STR1234 — this is expected actually. We can't query for multiple locales at once because that would require some performance overhead. We only query in the locale that you have specified (or the default locale).

You might want to find another pattern if you will be querying on this field often. Maybe specify the field separately once per locale?

@payloadcms payloadcms locked and limited conversation to collaborators Jun 10, 2024
@jmikrut jmikrut converted this issue into discussion #6706 Jun 10, 2024
@github-actions github-actions bot removed the status: needs-triage Possible bug which hasn't been reproduced yet label Jun 10, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants