I have a list of testimonials inside a group (using content relationship fields). I have been trying to access the data inside each testimonial within the list.
I realise I have to use GraphQuery but I am struggling to follow the instruction.
This is the JSON structure.
`{
"Main" : {
"prismic_title" : {
"type" : "StructuredText",
"config" : {
"single" : "heading6",
"label" : "Title (only used to name entry in Prismic list)",
"placeholder" : "This is used only to render a title in Prismic (otherwise we get \"undefined\")"
}
},
"page" : {
"type" : "Select",
"config" : {
"options" : [ "Homepage", "Option2", "Option3" ],
"label" : "Website page to appear on:"
}
},
"testimonial_list" : {
"type" : "Group",
"config" : {
"fields" : {
"testimonial" : {
"type" : "Link",
"config" : {
"select" : "document",
"customtypes" : [ "testimonial" ],
"label" : "testimonial"
}
}
},
"label" : "Testimonial List"
}
}
}
}`
Hi @devaccounts. When using Gatsby with Prismic, there is no need to use the GraphQuery option. GraphQuery is different than the GraphQL API and is meant to be used with the REST API.
Hi Levi, thanks for the response.
Okay, that makes more sense. Your page on One-to-many relationships tells us GraphQuery is the way to get content from groups, then links to GraphQuery - a little confusing.
Thanks for the link. I’ll look into it.
@devaccounts I’m glad that it makes more sense now. I’ll look at the One-to-many article and see if I can make it more clear that GraphQuery is only needed for the Rest API.
@Levi Following the page you linked I have navigated to where the testimonial content fields are being held and returns the correct amount of nodes, but my document returns null, is there a step I’m missing in order to populate the document field?
@devaccounts So I took a look and can’t see what the issue might be. From the little I know about this plugin, your query looks right to me.
The only thing I can think of would be to run gatsby clean and rebuild the gatsby site. If that doesn’t work, then maybe you can submit an issue via the plugin’s github issue page.
The first thing I can think of is that the schemas are no up to date.
For anything else I will need to investigate further to assist with this process a I will need a project that recreates the issue, and details about the prismic repository you are using.
So if updating the schemas doesn’t work let me know and we’ll start debugging the issue.