我正在尝试查询Gatsby中的Strapi Dynamic Zone中的数据。在Graphql Playground中,我可以让它工作,但在Gatsby中使用相同的查询,我在终端中收到以下错误:
error Unknown type "ComponentTextArticleCopy" graphql/template-strings

和我的article.js查询
export const query = graphql`
query ArticleTemplate($id: String!) {
strapiArticle(id: { eq: $id }) {
articleHeader {
articleTitle
articleSnippet
}
articleContent {
__typename
... on ComponentTextArticleCopy {
contentCopy
}
... on ComponentImageContentImg {
imgCaption
}
... on ComponentTextArticleQuote {
contentQuote
}
}
}
}
`根据Graphql docs的说法,内联片段似乎是正确的方法,但显然我在某些地方搞错了。
以下查询在Gatsby上“有效”,但尝试解析所有组件:
query MyQuery {
allStrapiArticle {
edges {
node {
__typename
articleContent {
contentCopy
contentQuote
}
}
}
}
}{
"data": {
"allStrapiArticle": {
"edges": [
{
"node": {
"__typename": "StrapiArticle",
"articleContent": [
{
"contentCopy": null,
"contentQuote": null
},
{
"contentCopy": "What a great city Gothenburg is. We even took a trip out to the archipelago. ",
"contentQuote": null
},
{
"contentCopy": null,
"contentQuote": null
},
{
"contentCopy": null,
"contentQuote": "You must visit at have fika"
}
]
}
}
]
}
},发布于 2021-09-20 16:34:13
删除缓存文件夹并再次运行对我有效。
https://stackoverflow.com/questions/66771816
复制相似问题