I'm building a multi language website with Prismic and Gridsome. I'm having trouble with fetching the data in other languages then my default language.
This is my query in the Prismic graphql editor:
query{
allProducts(lang:"en-us"){
edges{
node{
title
image
_meta{
uid
lang
uid
}
}
}
}
}
and this returns the data in that language.
This is the query on my local machine:
query {
allPrismicProduct(filter: { lang: { eq: "en-us" } }) {
edges {
node {
id
lang
data {
title
body
price
image {
url
}
}
}
}
}
}
And it returns an empty array with no data.
What am i doing wrong?
I can see that the structure of the schema is different, kind of how it's done when using Gatsby and the gatsby-source-prismic plugin. I'm not particularly familiar with Gridsome Prismic plugins or how many there are out there, the one I'm aware of is: gridsome-source-graphql-prismic is this the one that you're using?
At first glance I'm not able to see what the problem might be. So maybe by having more information we can figure this one out.
Could there be any missing multi language configuration that you need to add to the plugin config? e.g., sometimes you need to pass all the available languages in your repo so that the plugin understands how many there are and what to expect or pass in dynamically to the queries.
Thanks for reaching out. I was using the '@ilrock/gridsome-source-prismic' plugin for fetching the data.
I've switched to the 'gridsome-source-graphql-prismic' plugin and my query looks like this now:
query Post {
Prismic {
allProducts(lang: "de-de") {
edges {
node {
title
_meta {
lang
uid
}
}
}
}
}
}
This way i get all the data in all the languages so that problem is fixed! Thanks for pointing me in the right direction.
The only thing that doesn't work now anymore is creating pages from the prismic content. Guess i have to figure that out now!
Pau
closed , flag & select 'Something Else' to reopen.
5
This issue has been closed due to inactivity. Flag to reopen.