I'm having issues fetching data from linked documents and I've tried both the GraphQuery and FetchLinks methods but do not see the data returned. Here are my examples on my 'case_studies' custom type.
I'm glad you figured this out, although I'm not sure what you mean when you say "I'm still curious to know what I'm doing with the GraphQuery version.", can you give me more details?
When I tried using GraphQuery, I found that the data I was trying to fetch wasn't returned. I was attempting to get the title and overview_description fields from my Case Study type. The below code, didn't provide any errors, but the title and overview_description still weren't available on the case_study link field (as seen in the screenshot in my original post)
const homeQuery = `{
homepage {
data {
uid
body {
... on PrismicPageDataBodyContentCarousel {
non-repeat {
title
}
repeat {
title
case_study {
document {
... on PrismicCaseStudies {
data {
title
overview_description
}
}
}
}
}
}
}
}
}
}
`
export async function getStaticProps() {
const home = (await Client().getByUID('page', 'home', { 'graphQuery': homeQuery }))
return {
props: {
home,
},
}
}
In you getByUID query the type is page, but then in the GraphQuery you specify homepage. You also specifiy data in your GraphQuery which isn't necessary.
So it looks like the GraphQuery wasn't built correctly.