Internationalization graphql query

Hi , i am converting a site to internationalisation using Gridsome
in my gridsome.server.js I have the following.

        const { data } = await graphql(` {
  
            strapi {
            
                articles {
                    slug
                }
                categories {
                    slug
                }
                places {
                    slug
                }
            }
        }
    
    `);

This of course only brings me back the default locale. How do I change this to fetch, for example, all categories across all locales? How would I add a locale query to the categories in this example.

Best,

Jon

By default, the i18n plugin will return the record with the same locale as its parent. In this case, if strapi{...} in your example is by default ‘en’ then all localized relations to it will be ‘en’ as well. You can specify the locale you want in strapi{...} by changing your query to strapi(locale: "..."){...}. Theoretically, you can also do strapi(locale: "locale1"){..., categories(where: {locale: "locale2"}){...}} but it wont return the record if the locale isn’t the same as the parent locale.

ok thanks.
So, I think i need to iterate over all the locales that exist and fetch the collection for each one

1 Like

Any solution in order to get all locales?

A solution that would involve you creating a custom controller for that use would be the next best option.