Skip to content

fix(gatsby-source-strapi): Strapi v5 Fix "locale=all" i18n feature for Single Types and Collection Types#521

Open
SylvainGibert wants to merge 4 commits intogatsby-uc:mainfrom
SylvainGibert:fix/strapi-i18n-support
Open

fix(gatsby-source-strapi): Strapi v5 Fix "locale=all" i18n feature for Single Types and Collection Types#521
SylvainGibert wants to merge 4 commits intogatsby-uc:mainfrom
SylvainGibert:fix/strapi-i18n-support

Conversation

@SylvainGibert
Copy link

Description

Some of the job have been done previously to handle strapi v5 with this plugin, but, since they removed locale==all parameter when migrating strapi from v4 to v5, it is impossible to fetch multiple locales

See strapi migration page

So what i did is

  • Add support for locale='all' to fetch all available locales
  • Fix node ID conflicts by including locale in unique identifiers
  • Improve localization data handling for Strapi v5

The workflow i proposed consist in

  • fix easily for singleTypes
  • fix collectionTypes (fetchEntities func) by fetch an element with localizations, then loop on all locales to do one query per locale (and with actual system on pagination)

Documentation

no need to change, my PR contribute to keep the actual configuration

@moonmeister could you plase me send a feedback ? Thanks

Related Issues

Fixes #509

@changeset-bot
Copy link

changeset-bot bot commented Dec 15, 2025

🦋 Changeset detected

Latest commit: a6fa131

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
gatsby-source-strapi Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@laurenskling
Copy link
Contributor

I suggest you and @cjphs work together on this (#520). This needs extensive edge case testing, also for non-i18n setups. Your code at first lance looks like it won't work without locales.

@laurenskling
Copy link
Contributor

I'm not sure about the JSON change.. It has always been buggy but I don't think you should include changing that within this feature

@SylvainGibert
Copy link
Author

I suggest you and @cjphs work together on this (#520). This needs extensive edge case testing, also for non-i18n setups. Your code at first lance looks like it won't work without locales.

I just tested on a new strapi project without i18n and this kind of config and it works. (Projet with default locale en)

It fetched collectionTypes and singleTypes

const strapiConfig = {
  version: 5, // Strapi version 4 or 5
  apiURL: process.env.GATSBY_STRAPI_API_URL,
  accessToken: process.env.GATSBY_STRAPI_TOKEN,
  collectionTypes: [
    "blog-page"
  ]
  singleTypes: [
    "blog"
  ]

@SylvainGibert SylvainGibert force-pushed the fix/strapi-i18n-support branch from d026986 to a6fa131 Compare December 16, 2025 14:39
@SylvainGibert
Copy link
Author

I'm not sure about the JSON change.. It has always been buggy but I don't think you should include changing that within this feature

I agree, i pushed code a bit fast sorry ! I just tested when revert JSON code as it was and it worked normally

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(gatsby-source-strapi): When locale: "all" is used in a singleTypes error is thrown on a startup

2 participants