【发布时间】:2021-07-16 14:32:45
【问题描述】:
我正在使用 GraphQL 从 Wordpress 中的自定义 ACF 字段中提取信息到我的 Gatsby 网站。我的查询最初查询了三个 ACF 字段(ImageRow、TextRow 和 ImageTextRow),但是我随后删除了前两行并将它们从查询中删除。我那时。添加了一个名为 HeroRow 的新行,但是从那以后我一直收到此错误:
ERROR #85901 GRAPHQL
There was an error in your GraphQL query:
Fragment cannot be spread here as objects of type "WPGraphQL_Page_Customcontentblocks" can never be of
type "WPGraphQL_Page_Customcontentblocks_Customcontentblocks_HeroRow".
File: gatsby-node.js:82:28
我的查询如下:
query {
wpgraphql {
pages(first: 5000, where: {status : PUBLISH}){
nodes {
title
uri
status
content
customContentBlocks {
customcontentblocks {
... on WPGraphQL_Page_Customcontentblocks_Customcontentblocks_ImageTextRow {
fieldGroupName
version
imageV1 {
sourceUrl
}
titleV1
subtitleV1
textV1
linksV1 {
links {
target
title
url
}
}
imageV2 {
sourceUrl
}
titleV2
subtitleV2
textV2
listV2 {
listItem
}
ctaV2 {
target
title
url
}
}
}
... on WPGraphQL_Page_Customcontentblocks_Customcontentblocks_HeroRow {
fieldGroupName
title
image {
sourceUrl
}
links {
link {
target
title
url
}
}
}
}
}
}
}
}
如果我单独查询ImageTextRow,我可以毫无问题地查询它,但每当包含 HeroRow 时,我都会收到相同的错误消息。
我已以与 ImageTextRow 布局相同的方式设置 HeroRow 布局(两者都是兄弟,位于 customContentBlocks 字段组下),因此我希望查询对两者的工作方式相同。
我还使用GraphiQL IDE 在 Wordpress 端测试了查询,并且该查询在 Wordpress 端运行良好,问题似乎出在 Gatsby 端。
【问题讨论】: