Unknown argument "formatString" on field "date" of type "MarkdownRemarkFrontmatter".
See original GitHub issueReferencing: #26893 (and from a few years ago #2096) I tried removing all of my md files, then running gatsby clean
and then npm run develop
but I am still getting the
Unknown argument "formatString" on field "date" of type "MarkdownRemarkFrontmatter".
I am getting this error on three files:
blog-post.js
graphql query in question:
export const pageQuery = graphql`
query BlogPostBySlug($slug: String!) {
site {
siteMetadata {
title
}
}
markdownRemark(fields: { slug: { eq: $slug } }) {
id
excerpt(pruneLength: 160)
html
frontmatter {
title
date(formatString: "MMMM DD, YYYY")
description
}
}
}
`
search.js
graphql query in question:
export const pageQuery = graphql`
query {
allMarkdownRemark(sort: { order: DESC, fields: frontmatter___date }) {
edges {
node {
excerpt
id
frontmatter {
title
description
date(formatString: "MMMM DD, YYYY")
}
fields {
slug
}
}
}
}
}
`
index.js
graphql query in question:
export const pageQuery = graphql`
query {
site {
siteMetadata {
title
}
}
allMarkdownRemark(sort: { fields: [frontmatter___date], order: DESC }) {
edges {
node {
excerpt
fields {
slug
}
frontmatter {
date(formatString: "MMMM DD, YYYY")
title
description
}
}
}
}
}
`
Interestingly after deleting all the md files I got a new message:
ERROR #85923 GRAPHQL
There was an error in your GraphQL query:
Cannot query field "frontmatter" on type "MarkdownRemark".
If you don't expect "frontmatter" to exist on the type "MarkdownRemark" it is most likely a typo.
However, if you expect "frontmatter" to exist there are a couple of solutions to common problems:
- If you added a new data source and/or changed something inside gatsby-node.js/gatsby-config.js, please try a restart of your development server
- The field might be accessible in another subfield, please try your query in GraphiQL and use the GraphiQL explorer to see which fields you can query and what shape they have
- You want to optionally use your field "frontmatter" and right now it is not used anywhere. Therefore Gatsby can't infer the type and add it to the GraphQL schema. A quick fix is to add at least one entry with that field ("dummy content")
It is recommended to explicitly type your GraphQL schema if you want to use optional fields. This way you don't have to add the mentioned "dummy content". Visit our docs to learn how you can define the schema for "MarkdownRemark":
https://www.gatsbyjs.org/docs/schema-customization/#creating-type-definitions
A few days ago this bug popped up after a git commit. Everything was working fine then I pushed some mobile header/tailwind adjustments to my repo and this error popped up. My temporary workaround is to delete
(formatString: "MMMM DD, YYYY)
from the query.
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (1 by maintainers)
Top Results From Across the Web
getting graphQL error when compiling - Stack Overflow
GraphQL Error There was an error while compiling your site's GraphQL queries. Invariant Violation: GraphQLParser: Unknown argument `formatString ...
Read more >Gatsby Development 101 - A Condensed Tutorial
This caused me 2 hours of debugging, so if you get "Unknown argument "formatString" on field "date" of type "MarkdownRemarkFrontmatter" when ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
the type of your frontmatter date field has changed from
Date
toString
. Most likely the reason (at least for me) it is that one of your posts has an invalid date (in my case I haddate: 2020-079-20T08:11:45+02:00
). Check all your frontmatter dates and ensure that they are valid.@osseonews Per chance did you try
gatsby clean
before runninggatsby develop
? I read that had helped some folks… Fortunately for me I only 16 md files to go through, but 14 of those md files the date field had been wrapped in""
which was causing my error.I ended up going in and changing all the date fields from this format:
date: "April 15, 2015"
into this format:date: 2015-04-15T03:13:00+02:00
runninggatsby clean
and thengatsby develop
and the error was gone