gatsby-source-datocms: localeFallbacks not working in latest versions.
It appears that localeFallbacks don’t work as expected in newer versions of gatsby-source-datocms
our defined localeFallbacks
localeFallbacks: {
'en-DE': ['en'],
'en-FR': ['en'],
'en-BE': ['en'],
'en-NL': ['en'],
'en-GB': ['en'],
'en-US': ['en'],
'en-EU': ['en'],
'fr-FR': ['fr', 'en'],
'fr-BE': ['fr', 'en'],
'nl-NL': ['nl', 'en'],
'nl-BE': ['nl', 'en'],
'de-DE': ['de', 'en'],
}
Below Im posting 3 examples of data being returned differently for different versions of those plugins. The query is the same across all 3 examples.
Example 1 (Working as expected):
gatsby-source-datocms@3.0.15
datocms-client@3.5.9
Screenshot from /___graphql:

Example 2 (Not Working):
gatsby-source-datocms@4.0.4
datocms-client@3.5.9
Screenshot from /___graphql:

Example 3 (latest versions - Not Working)
gatsby-source-datocms@4.0.4
datocms-client@3.5.21
Screenshot from /___graphql:

About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 21 (15 by maintainers)
Above fix was just published in
gatsby@next(concrete version right now isgatsby@4.24.0-next.0).@jpriceharrys If you debug the lines I linked above the logic says the following:
Object.keys(entity[camelize(firstLocalizedField.apiKey)]);, @jpriceharrys please verify if you can)If my understanding is correct, given your more detailed post above, I now consider this a bug with
gatsby-source-datocms. Because just as you say, you are required to fill in a value for a locale for a Gatsby Node to be created for that locale.The
localeFallbacksoption will only get processed for locales that have a value, which kind of defeats the purpose. @stefanoverna do you agree?If so should the logic change to include
localeFallbacksin the decision forlocalesToGenerate? I think that all locales that have a fallback defined inlocaleFallbacksshould get a Gatsby Node generated with the fallback value. I can probably get a PR drafted if this is something the maintainers are willing to merge.That is correct @michaellopez.
We’re currently talking with Gatsby to see if we can do any better than this.
Ideally, we’d like to replicate the way localization works with our GraphQL API. This would allow us to generate only one Gatsby node per record, and let the developer customize the locale (and fallback locales) to be returned on a per-field level… but some pieces are missing in the Gatsby API atm.
I’ll keep you posted!