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