i am going through this tutorial: https://www.gatsbyjs.org/blog/2017-07-19-creating-a-blog-with-gatsby/
I have completed everything, and I am getting a graphQL compile error:
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`.
Here is my query:
export const pageQuery = graphql`
query BlogPostByPath($path: String!) {
markdownRemark(frontmatter: { path: { eq: $path } }) {
html
frontmatter {
date(formatString: "MMMM DD, YYYY")
path
title
}
}
}
`
;
The compile error points to the date object, and when i remove it, the date compile error goes away. What is wrong with my date object?
There is nothing wrong with your date object date(formatString: "MMMM DD, YYYY")
itself.
Rather, check your markdown file and make sure you are using the proper format in your frontmatter. I assume that's where your issue is stemming from.
Examples:
A date like this (there's no 77th month in a year) will throw the error you are getting:
---
path: "/hello-world"
date: "2017-77-12"
title: "My First Gatsby Post"
---
Similarly, a date like this (there's no 88th day in a month) will also throw the error you are getting:
---
path: "/hello-world"
date: "2017-07-88"
title: "My First Gatsby Post"
---
Those are extreme examples, but I think you catch my drift by now, so try fixing your frontmatter date so that the month, day, and year make calendrical sense.
I had a similar issue; fixed all my dates as recommended but the error still persisted. At the time of testing, I was running in Powershell:
gatsby develop
I stopped that using CTRL-C and Y
to cancel, restarted the gatsby development server and the query then worked. When in development mode, gatsby caches certain things and it wasn't picking up the frontmatter changes to my files.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With