[英]getting graphQL error when compiling
我正在阅读本教程: https : //www.gatsbyjs.org/blog/2017-07-19-creating-a-blog-with-gatsby/
我已经完成了所有事情,我收到了graphQL编译错误:
GraphQL Error There was an error while compiling your site's GraphQL queries.
Invariant Violation: GraphQLParser: Unknown argument `formatString`.
Source: document `BlogPostByPath` file: `GraphQL request`.
这是我的查询:
export const pageQuery = graphql`
query BlogPostByPath($path: String!) {
markdownRemark(frontmatter: { path: { eq: $path } }) {
html
frontmatter {
date(formatString: "MMMM DD, YYYY")
path
title
}
}
}
`
;
编译错误指向日期对象,当我删除它时,日期编译错误消失。 我的约会对象有什么问题?
您的日期对象date(formatString: "MMMM DD, YYYY")
本身没有任何问题。
而是,检查您的降价文件,并确保您在frontmatter中使用正确的格式。 我认为这是你的问题所源自的地方。
例子:
像这样的日期( 一年中没有第77个月 )会抛出你得到的错误:
---
path: "/hello-world"
date: "2017-77-12"
title: "My First Gatsby Post"
---
同样,这样的日期( 一个月内没有第88天 )也会抛出你得到的错误:
---
path: "/hello-world"
date: "2017-07-88"
title: "My First Gatsby Post"
---
这些是极端的例子,但我认为你现在已经抓住了我的漂移,所以尝试修复你的前置日期,以便月,日和年具有日历意义。
我有类似的问题; 修复了我推荐的所有日期,但错误仍然存在。 在测试时,我在Powershell中运行:
gatsby develop
我停止使用CTRL-C和Y
取消,重新启动gatsby开发服务器,然后查询工作。 在开发模式下,gatsby会缓存某些内容,并且没有对我的文件进行前端更改。
它应该是“MMM”而不是“MMMM”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.