-
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 Field "image" must not have a selection since type "String" has no subfields. #4123
Comments
Check for case differences in filenames: f.e. |
There are no case differences. The only differences are in file type, |
@dajocarter delete fields with empty strings completely and keep fields that actually point to a file - when we construct schema types we check if string does look like a path and empty string does not so we don't transform it to File link |
@pieh That fixed my issue. Thanks for your help! |
@pieh It should be specified somewhere. It's a strange behavior if no image in frontmatter is transformed to sharp node if there is an empty value hidden somewhere in a file |
@pieh Could you tell me where the "check if string does look like a path" in the gatsby code ? I did not find it |
@xuopled https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby/src/schema/types/type-file.js#L28 Problem here will be that we compile all nodes to create representative data sample. So it will see that string is empty - but we can't tell if that's just string field or file field at this point, so we would need to adjust compiling down example node to prefer non-empty strings over empty strings for generating representative object (somewhere here https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby/src/schema/data-tree-utils.js ) |
I had this issue, what fixed it for me was taking all the images out of the folder, doing a git commit and putting them back with the correct .JPG or .jpg Hope that helps someone |
I used the correct .jpg or JPG, but it still didn't work. So I ended up recloning my repo, |
Thanks mate, it fixed my error too. |
Darn, what a terrible fix. |
@kpennell the issue is that these are incredibly hard to reproduce and vary based on machine setup. Oftentimes this is caused by some type of Sharp error out of our control, so if you can reliably reproduce this we'd love to take a look. |
Wondering if things to check are:
I made an SO question here: https://stackoverflow.com/questions/55736780/what-causes-the-string-has-no-subfields-image-error-in-graphql-gatsby Anyway, sorry to be one more person with this issue. |
I recently upgraded from gatsby@^2.1.0 to @^2.15.33, using netlify-cms. In order to bypass this error for certain fields, in addition to checking to make sure you don't have any imageFieldName: "", you also have to make sure there are no empty container arrays. eg. for
you need to make sure you don't have any |
@nbw's solution of restarting the development environment worked for me. It seems like when updating markdown files while |
i restarted my dev server with "gatsby clean" and it doesn't help me. Look like bug |
Edit: This comment has incorrect information. In my example, I set After hours debugging this, I decided to make the simplest possible example to show how broken this error truly is. I forked the official gatsby-starter-blog and did nothing but add an "image" property to the frontmatter for the A few other things I made sure to do that didn't fix the issue:
If I were you reading this, I would recommend giving up on this functionality before you waste any more time. If even a simple implementation forked off of Gatsby's official starter blog doesn't work, I don't know what would. |
This bug is consistently happening across all different machines. Can this please get addressed? |
@jacknugent Please note that your error is here: https://github.com/jacknugent/gatsby-starter-blog/blob/master/gatsby-node.js#L109 You're forcing the |
@LekoArts thank you for pointing that out. I confirmed that solution works, and I added an edit to the top of my comment. I must have overlooked how the docs for preprocessing external images does exactly what you suggested. I think Gatsby's troubleshooting for this issue should include using |
This actually fixed it for me... Time was wasted. |
Description
I've been getting this error everytime I deploy to Netlify and most times in development. The only way I seem to be able to get around it in development is to delete node_modules and
yarn install
, and even this doesn't work every time. If I do get around it in development and I stopgatsby develop
, the next time I run it, it comes back and I have to repeatedly delete node_modules andyarn install
until it works again.My directory structure looks like
my post frontmatter looks like
my graphQL query looks like
Environment
Gatsby version: 1.9.202
Node.js version: v8.1.3
Operating System: OSX
File contents (if changed):
gatsby-config.js
:package.json
:gatsby-node.js
:The text was updated successfully, but these errors were encountered: