Locale passed in page context not working in query

We are trying to upgrade our gatsby-source-datocms ( to version 5.0.3) package, which implies updating queries made. There’s a query we do for a model BlogPost, which is localised. We pass the value of the $locale argument via PageContext.

console.log(props.pageContext.locale);

yields "de-DE" when the url points to /de/bla-bla , the problem is that the content shown is not from the de-DE locale, the graphql query with variable passed through PageContext didn’t work.

The query:


query BlogPostPageQuery(
    $originalId: String!
    $locale: String!
    $categorySlug: String!
    $tagName: String
    $relatedBlogPostLimit: Int!
  ) {
    datoCmsBlogpost(locale: $locale, originalId: { eq: $originalId }) {
      originalId
      id
      title
      metaDescription
}

It’s like the GraphQL is not getting the value for $locale via pageContext. But if I hard code the locale value it works.

query BlogPostPageQuery(
    $originalId: String!
    $locale: String!
    $categorySlug: String!
    $tagName: String
    $relatedBlogPostLimit: Int!
  ) {
    datoCmsBlogpost(locale: "de-DE", originalId: { eq: $originalId }) {
      originalId
      id
      title
      metaDescription
}

Not sure why pageContext is not passing the value for the locale

hey @technology sorry for the delay here.

Are you using the same method now with a previous version of the source plugin and is it working? Can you please provide more details also on the Gatsby version that you are using?

The pageContext is filled only at build time, so maybe you are hitting some limitation of that? If you can give me a bit more info I’ll try reproducing on my end. Thanks!