【发布时间】:2020-10-16 12:52:38
【问题描述】:
问题:
我正在使用 Prismic 将数据发送到我的网站。
在 Prismic 中,我有一个类型 (testimonial_list),它由一组内容关系字段 (Prismic Type testimonials) 组成。
要查询内部类型的数据,我需要通过 graphql 中的文档字段访问它们并使用内联片段。
我已按照此处的说明进行操作: https://github.com/angeloashmore/gatsby-source-prismic#Query-Content-Relation-fields
在 graphql 中,我设法导航到 testimonial 数据字段(在 document 字段上),但 document 字段返回 null,这就是我卡住的地方。我不知道为什么它会返回 null,因为内容存在并且在 graphql 中清楚地找到了这些字段。
信息:
我的项目是使用 Gatsby 构建的,我正在使用插件 gatsby-source-prismic v3.1.1
在这里您可以看到我可以访问正确的字段数据,并且返回了正确数量的节点,但 document 为空:
这是 Prismic 上 testimonial_list 类型的 JSON:
{
"Main" : {
"prismic_title" : {
"type" : "StructuredText",
"config" : {
"single" : "heading6",
"label" : "Title (only used to name entry in Prismic list)",
"placeholder" : "Prismic list title (otherwise \"undefined\")"
}
},
"page" : {
"type" : "Select",
"config" : {
"options" : [ "Homepage", "Option 2", "Option 3" ],
"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"
}
}
}
}
感谢您的帮助,如果我可以提供更多信息来帮助推断问题,请告诉我。
【问题讨论】:
标签: graphql gatsby prismic.io