错误 无法查询类型"查询"上的字段"所有StrapiArticles"



我刚刚开始了我的第一个Strapi and Gatsby项目。在刚刚升级到Gatsby CLI 3.0之后,我得到了以下错误:

Cannot query field "allStrapiArticles" on type "Query"

我的整个文件:

import React from "React"
import { Link, graphql } from "gatsby"
import Navbar from "../components/navbar"
import Footer from "../components/footer"
const IndexPage = ({ data }) => (
<div>
<Navbar />
<h1>Articles</h1>
<p>Colleciton of Photo Editorials</p>
<ul>
{data.allStrapiArticles.edges.map(document => (
<li key={document.node.id}>
<h2>
<Link to={`/${document.node.id}`}>{document.node.Title}</Link>
</h2>
<p>{document.node.Snippet}</p>
</li>
))}
</ul>
<Footer />
</div>
)
export default IndexPage
export const pageQuery = graphql`
query IndexQuery {
allStrapiArticles {
edges {
node {
id
Title
Snippet
}
}
}
}
`

我从Strapi的schema如下:

type Articles {
id: ID!
created_at: DateTime!
updated_at: DateTime!
Title: String
Snippet: String
Content: String
category: Category
published_at: DateTime
image(sort: String, limit: Int, start: Int, where: JSON): [UploadFile]
tags(sort: String, limit: Int, start: Int, where: JSON): [Tags]
}

由于使用单数"Article",我最初确实有一个问题,但已经纠正为复数,我还注意到这是大小写敏感的,需要大写的"Title"one_answers"Snippet"。但是,正如我所说,在升级到3.0之前,我已经把这个工作得很好了,我不知道CLI会如何影响这个。

在那个版本中是否有我错过的重大变化?

我强烈建议降级到v2,直到所有插件和依赖项的代码适应当前稳定的v3。盖茨比最近刚刚发布了v3,你知道,它的代码在"本机"上运行得很好。用例来源,或者换句话说,当从markdown、json等收集数据时

所有与插件相关的解决方案,或者当从外部CMS获取数据时,总是需要一个插件,代码严格依赖于插件的实现,所以,直到Strapi(在这种情况下)不更新代码,你将无法使用盖茨比的v3而不会遇到错误,问题或警告。

最新更新