Singletypes and Locale(s) doesn't return translations

Hi There.
I have created a new project with the latest version of gatsby, gatsby-strapi-plugin and strapi itself.

I have added the configuration for strapi to gatsby-config.js

    {
      resolve: `gatsby-source-strapi`,
      options: {
        apiURL: `http://localhost:1337`,
        queryLimit: 1000, // Default to 100
        singleTypes: [
          { 
            name: 'homepage',
            api: { qs: { _locale: `all` } }
           }
        ]
      },
    },

I have a SINGLE TYPE called homepage with an titleand localization enabled.
However querying strapi with graphql only returns the english title and not the other locales which is defined

query MyQuery {
  allStrapiHomepage {
    edges {
      node {
        id
        Title
        locale
        localizations {
          locale
        }
      }
    }
  }
}

returns:

{
  "data": {
    "allStrapiHomepage": {
      "edges": [
        {
          "node": {
            "id": "Homepage_1",
            "Title": "xxx Track Day xxx",
            "locale": "en",
            "localizations": [
              {
                "locale": "da",
              },
              {
                "locale": "sv-SE",

              }
            ]
          }
        }
      ]
    }
  },
  "extensions": {}
}

Is this the intended behaviour or am I missing something?

2 Likes

Hi, I have the exact same problem, did you figure it out?

1 Like

Not so far, and as I can see is every language in a separate node and that is probably the reason that it only returns a single node.

The difference between the Collection types and th Single types is that the latter return node [] and not nodes []

But it would be nice if a maintainer or developer could take a look at this.

1 Like

Hi, maybe this could help:
gatsby-config.js

{
      resolve: "gatsby-source-strapi",
      options: {
        apiURL: process.env.API_URL || "http://localhost:1337",
        collectionTypes: [
          {
            name: `post`,
            api: { qs: { _locale: `all` } },
          },
        ],
        singleTypes: [
          {
            name: "homepage",
            api: {
              qs: {
                _locale: "de",
              },
            },
          },
          {
            name: "homepage",
            api: {
              qs: {
                _locale: "en",
              },
            },
          },
          `global`,
        ],
        queryLimit: 1000,
      },
    },

query:

query MyQuery {
  allStrapiHomepage {
    nodes {
      Title
      locale
    }
  }
}

Result:

{
  "data": {
    "allStrapiHomepage": {
      "nodes": [
        {
          "Title": "GrenzĂĽberschreitende Logistik leicht gemacht",
          "locale": "de"
        },
        {
          "Title": "Cross-border logistics made easy",
          "locale": "en"
        }
      ]
    }
  },
  "extensions": {}
}
1 Like

It definitely does, however, this still feels like a workaround since we have to add an entry to the config file for each locale…