Locale filter doesn't work

I have a data model called Podcast which doesn’t have translation currently enabled, however it is queried within a generic function that often does have translated content, so it is queried for various locales.

My issue is that no matter what locale is queried, the content is returned.

For example, this query returns 3 results despite no Japanese content being available:

query MyQuery {
  allPodcasts(locale: ja) {
    id
  }
}

Actually this is worse than I thought. The locale filter doesn’t work right at all. Even on translated content types it’s returning results that aren’t of the locale requested.

Hi @kaushik :slight_smile:

records do not have a “locale” per se. Localization is a setting you enable/disable on a single field. So, this means that it’s a field that has some locales, not a record.

I suppose that the Podcast model has a localized field. Let’s call it title. If you wanna fetch all of the podcasts ids where the title has a japanese locale, then you should do a graphql query like this:

query MyQuery {
  allPodcasts(locale: ja, filter: {title: {neq: ""}}) {
    id
  }
}

Hope this clarifies a bit! :slight_smile:

So it’s normal/expected that on a model with no localized fields, that query you posted returns results?

Because that seems wrong to me.

Yes it’s normal. A query like this:

query MyQuery {
  allPodcasts(locale: ja) {
    id
    title
  }
}

means: fetch all podcasts and for each podcast, get me the id and the title. If title has a japanese content, show me that content in japanese, otherwise returns me an empty string.

If you wanna retrieve only the podcasts with a title in japanese, then you need to filter like in the previous post :slight_smile: