-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GraphQL Error when cache is deleted: Unknown field date
on type frontmatter
#2096
Comments
Not really sure what is causing this. Could you please create a simple site reproducing the problem? |
Turns out this was because some of our posts generated through our CMS did not have quotation marks around the dates in the frontmatter. Where would be a good place to document requirements for frontmatter fields, @KyleAMathews? Since other generators (was using Jekyll prevously and had no problem) do not require this, it would be good to document this somewhere. Happy to open a PR. |
This should have fixed it #1964 Can you check if you're on the latest version of Gatsby? |
Yeah I was on version 1.9.27 when reporting this, and created a simple site with the latest version (1.9.32, just re-tried it this morning), and it still does not quite work. |
Could you build a small reproduction site for this that I could take a look at? |
I think I've encountered the same issue. In my case, I was testing Netlify CMS which generates markdown using its
This resulted in the same error seen by @attfarhan:
For me, it also only happens the first time I try to build (i.e. when there is no Manually adding the quotation marks around the date made the error disappear. I put together a quick repo for you to check if that helps - https://github.com/josephrace/gatsby-date-issue - it's mostly just code from the "Programatically creating pages from data" page of the tutorial, with 2 example markdown files in |
…es when inferring GraphQL types fixes #2096
Ok, so figured out the problem. Our frontmatter parser gray-matter uses js-yaml under the hood to parse the YAML in frontmatter which in turn parsers ISO 8601 compliant strings to JavaScript date objects. Which causes trouble when there's (as in the case of your very nice repro site) fields that have both ISO 8601 dates and ones that aren't as the first gets turned into a date object and the other stays as a string. Because when we try to infer the type of the field, we get a type mismatch which we just declare invalid and ignore. Hence why the date field was ignored. So #2163 solves this by stringifying all date objects in frontmatter so that regardless of the date format you use, they'll all end up strings so will get inferred in the end as date fields. Thanks for everyone who chimed in on this issue and @josephrace for building the reproduction site!! |
@KyleAMathews Sorry for the super delayed response, got busy with a product release, which includes our new marketing site built on Gatsby :). Thanks @josephrace for taking creating the sample repo. Glad this got solved! |
Thanks Kyle, this is working for me with gatsby-transformer-remark@1.7.9 |
This is an issue again. Current version of gatsby, and gatsby-transformer-remark (2.3.8) require date fields to be wrapped in quotes. e.g. frontmatter
frontmatter with quotes around the date works just fine. e.g.
|
Appears to still be an issue in gatsby 2.19.45, gatsby-transformer-remark: 2.6.59, even with quotes around the date -
|
I am building a Gatsby typescript project and I keep getting this error
Unknown field
dateon type
frontmatter`` in one of my queries. I have made sure that every entry has a date field, and I can see that in the graphql typings file that the schema does include this date field.What I found is that this only occurs when the cache is empty (when doing a fresh build with no .cache directory), so I am unable to deploy my site using continuous deployment.
The query is:
My gatsby config is:
package.json:
The text was updated successfully, but these errors were encountered: