Frontmatter: Field "image" must not have a selection since type "String" has no subfields
See original GitHub issueHi, I just have updated my dependencies to their last public version:
"gatsby": "^2.16.5",
"gatsby-image": "^2.2.29",
"gatsby-plugin-manifest": "^2.2.23",
"gatsby-plugin-netlify": "^2.1.22",
"gatsby-plugin-netlify-cms": "^4.1.25",
"gatsby-plugin-react-helmet": "^3.1.13",
"gatsby-plugin-sharp": "^2.2.32",
"gatsby-remark-images": "^3.1.28",
"gatsby-remark-relative-images": "^0.2.2",
"gatsby-source-filesystem": "^2.1.33",
"gatsby-transformer-remark": "^2.6.30",
"gatsby-transformer-sharp": "^2.2.23",
"netlify-cms-app": "^2.9.7",
"react": "^16.10.2",
"react-dom": "^16.10.2",
"react-helmet": "^5.2.1"
After this update, I have deleted cache and node_modules folders and did a fresh install to be on a good base.
I have an image widget in the frontmatter and it was working totally fine until netlify-cms-app 2.9.6. In 2.9.7, with the graphQL explorer, I see that this image field is no longer working as an image but just as a string. So it doesn’t have anymore id, publicURL, etc.
Of course now, I’m getting this gatsby error as the image doesn’t have subfields anymore:
Field "image" must not have a selection since type "String" has no subfields
Does anyone has encountered this weird behavior with the last version of netlify-cms-app?
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:13 (3 by maintainers)
Top Results From Across the Web
Field "image" must not have a selection since type "String" has ...
Field "image" must not have a selection since type "String" has no subfields. ... "value" to exist, the field might be accessible in...
Read more >Field "image" must not have a selection since type "String" has ...
Going on 3 days now. I'm getting the common: Field "image" must not have a selection since type "String" has no subfields.
Read more >“Field “image” must not have a selection since type “String ...
I was trying to query an image I'd placed in the frontmatter of a post, when I got the error: Field... Tagged with...
Read more >Setting up a cover image for your blog template with Gatsby ...
Field "featuredImage" must not have a selection since type "String" has no subfields. This can happen if you e.g. accidentally added { }...
Read more >error: 'field `image` must not have a selection since type `string ...
Field 'image' must not have a selection since type “String” has no subfields. The query should have worked because image in my case, ......
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 Free
Top 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
I have been experimenting around this issue. Here are my observations about the behavior of netlify-cms with a field in the frontmatter, in this case an image widget. There are 3 possibilities and one is provoking the famous
Field "image" must not have a selection since type "String" has no subfields
:Case 1: The image is selected and everything is working fine in the markdown:
image: /assets/image.jpg
Case 2: The image selected is now deleted through the admin interface. It’s rendering this empty string in the markdown file:
image: ''
This is causing the errorField "image" must not have a selection since type "String" has no subfields
in gatsby.Case 3: There is no image at all and the field is empty in the interface. It’s rendering no field in the markdown and everything is working fine.
@erquhart What is the best way to avoid this behavior? Would it be possible to delete the field in the markdown instead of having the empty string? It’s happening often that a user or a client deletes a frontmatter’s image in the admin.
@hppRC Thanks for these snippets but I have them already working. The problem is not about the relative path. This is working with the fix and
gatsby-remark-relative-images
package.The problem is how netlify-cms write, update or delete data in the markdown file. Specially with image. In the admin interface, if you delete an image already existing in an image field/widget, it will write an empty string instead of deleting the whole field. So the problem is the co-existence of these 3 cases (a field with path, a field with an empty string and no field) in a series of markdown files. @erquhart Am I doing something wrong? Or the only one with this problem?