Skip to content
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

Compilation fails when there's no featuredImage field #15

Open
tzuntar opened this issue Jun 8, 2020 · 0 comments
Open

Compilation fails when there's no featuredImage field #15

tzuntar opened this issue Jun 8, 2020 · 0 comments

Comments

@tzuntar
Copy link

tzuntar commented Jun 8, 2020

I've tried adding a new post, but when running gatsby develop, the site won't compile anymore:

There was an error in your GraphQL query:

Cannot query field "featuredImage" on type "MarkdownRemarkFrontmatter".

If you don't expect "featuredImage" to exist on the type "MarkdownRemarkFrontmatter" it is most likely a typo.
However, if you expect "featuredImage" 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 "featuredImage" 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 a 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 "MarkdownRemarkFrontmatter":
https://www.gatsbyjs.org/docs/schema-customization/#creating-type-definitions

File: E:/Website/src/templates/blog-post.js

This is the file I've added:

---
title: Test
date: "2020-06-08"
---

This is a test...

I've tried removing all other pages (no effect) and running gatsby clean before running gatsby develop/gatsby build (no effect). Adding an empty featuredImage field doesn't work either. But if I delete my pages and restore the 3 example ones, it compiles without problems.

In case it helps, I'm using Gatsby through NPM on Windows 10.

Is there anything I'm missing?

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant