-
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
Getting error 'Cannot query field "draft" on type "Frontmatter".' #546
Comments
I'm getting the same error. Removed all the blog posts, put in my own and was greeted with this. Then I restored all the previous posts and the error continued. I suspect it might be some cache problem. I think I got finally got around by adding This is on 1.0.0-alpha9. |
There hasn't been any time spent on improving the errors in the new stuff so that error is a bit ambiguous. What's happening is in my blog — I add The error comes from the fact that the blog index page queries for the draft field (see https://github.com/KyleAMathews/blog/blob/90e9c2979b54f08b76ddd7e9f7101b6ba93d6353/pages/index.js#L79). Gatsby extracts the graphql queries from pages and runs them and then injects their results as props into the component. This lets you query for exactly the data you need for a page. But since you removed the markdown files with So the solution would be to modify the queries to remove all mentions of the draft field. Thanks for checking out the 1.0 stuff! I salute your bravery :-) I'll be starting to work on upgrade + conceptual/API docs soon as I finish fleshing out the final pieces. |
@iiroj @KyleAMathews thanks for answers, closing issue. Offtop: Kyle, did you drop your idea about SimpleGTD? I highly resonate with your concerns you've introduced in your blogpost. I would like to discuss that and compare your ideas with mine :-) |
@hyphen-wrex yeah — 1) didn't think building a TODO app was worth my time and 2) I decided there are better ways to think about productivity e.g. this book and this one |
@KyleAMathews is there a way to manually add a field to the schema, in case you want to keep this functionality but don't have any draft pages at the moment (ie. could be added in the future?) Edit: solved it by adding the property with a default false to pages. Still wonder if there is a way to declare a schema. |
@cupojoe not yet possible - schema is constructed just from existing data. There is defenitely plan to add way to declare schema after Gatsby v2 is released |
you can achieve this by using createNode with a default value createNodeField({
node,
name: 'draft',
value: draft || false,
}); |
I cloned Bricolage.io site with Gatsby, develop was working great, except hot reloading wasn't working at all, not big deal I think, it is alpha version overall.
Then I deleted everything except favicon.ico, index.js, robots.txt, tags.js in pages folder to write my own blog posts, wrote couple of them and when I use "gatsby build" in command line, getting this error: 'Cannot query field "draft" on type "Frontmatter".'
Is it possible to workaround this problem? If not, what is the appropriate way to populate Kyle Mathews style blog with my own posts? Or is it simply not possible and I should get things done from scratch using one of Gatsby simple starters?
Update: for someone getting the same error, you should remove draft field from GraphQL queries in following files:
The text was updated successfully, but these errors were encountered: