Query to filter entries with locale being defined won't check fallback

I have a search field I’m returning auto suggestions for. In this case the input is being compared with the entry’s title field. It works fine, but I’m currently trying to implement localization for this specific query:

export const NEWS_AUTO_SUGGESTIONS = gql`
    query GetNewsAutoSuggestions($query: String!, $locale: String) {
        newsArticleCollection(limit: 15, locale: $locale, where: { title_contains: $query }) {
            items {
                sys {
                category {

Default and fallback locale is en-US
The issue I have is, that when f.e. the german locale de is set, only entries that have a german title are being queried, how can I also query the fallback entries though?

It is expected that the fallback does not apply. The reason is that the fallback mechanism is applied after doing the query, so a query with locale=de will search for matching entries using that locale but without taking into account any fallbacks.

As a workaround, you could use aliases to combine multiple queries of different locales and then on the front end, check if de is returned, and if not, use en-US

1 Like

The “fallback” seems pretty useless then from an API standpoint. For example, let’s pretend I have an Article content type and it has a slug field that can be localized for en-US, en-CA, and fr-CA. The slug value is the same for both en-US and en-CA so ideally we would rely on Contentful’s fallback mechanism so that an author only has to fill in a slug for en-US; en-CA will then share that same value. However, when I go to query on articleCollection(locale: "en-CA", where: { slug: "my-english-slug" }), I will get 0 results because the en-CA article technically has no slug. The workaround you provided essentially doubles the number of API calls we would have to make and also doesn’t work for when you need to sort a collection via the API. For example, if I try to sort by slug in en-CA, the results will not actually be sorted because every entry will technically have a null value for slug. In order for us to leverage Contentful’s filtering/sorting capabilities in Graph, we would need to force our authors to input values for EVERY locale, even if that locale’s value is no different then its fallback value, which creates a lot of unnecessary work for our authoring team.

1 Like