Skip to content

Getting an item by other than default locale slug #231

@GreenberryServiceAccount

Description

I'm currently migrating from gatsby-source-datocms v4 to v5, but I'm having some trouble getting it to work. My default locale in DatoCMS is "en" and the other locale I'm using is "nl". In the previous version I could fetch an item based on the "nl" slug, but that doesn't seem to work in version 5 anymore. This should really be possible, because if, for example, I'm navigating to /nl/nieuws/mijn-eerste-nieuws I only know that my Dutch slug is mijn-eerste-nieuws. I don't have the "original" English slug at my disposal. Some items don't even have an English version.

I've verified that this issue exists by using the graphql explorer locally at http://localhost:8000/__graphql, by first getting an article in Dutch by using the English slug, eg:

query getArticle {
  data: datoCmsArticle(
    slug: { eq: "my-first-article" }
    locale: "nl"
  ) {
    title
    slug
    intro
    date
  }
}

This gives me the correct article in Dutch, so the "locale" argument is working.

I don't get any response when I try to use the Dutch slug however, eg:

query getArticle {
  data: datoCmsArticle(
    slug: { eq: "mijn-eerste-artikel" }
    locale: "nl"
  ) {
    title
    slug
    intro
    date
  }
}

Am I missing something? There must be a way to get a specific article based on the slug in any translation, right?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions