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

Field "hero_image" must not have a selection since type "String" has no subfields. #9

Open
dantubb opened this issue Aug 16, 2020 · 12 comments

Comments

@dantubb
Copy link

dantubb commented Aug 16, 2020

Hi, I've taken a local copy and when i run "yarn dev" without making any changes I am getting the error below

`There was an error in your GraphQL query:

Field "hero_image" must not have a selection since type "String" has no subfields.

This can happen if you e.g. accidentally added { } to the field "hero_image". If you didn't expect "hero_image" to be of type "String" make sure that your input source and/or plugin is correct.

File: C:/Users/dantu/WebstormProjects/brevifolia-gatsby-forestry/src/static_queries/useBlogData.js

There was an error in your GraphQL query:

Field "hero_image" must not have a selection since type "String" has no subfields.

This can happen if you e.g. accidentally added { } to the field "hero_image". If you didn't expect "hero_image" to be of type "String" make sure that your input source and/or plugin is correct.

File: C:/Users/dantu/WebstormProjects/brevifolia-gatsby-forestry/src/templates/blog.js`

@Xananax
Copy link

Xananax commented Aug 28, 2020

Same, I haven't been able to understand where the error comes from

@Xananax
Copy link

Xananax commented Aug 29, 2020

I fixed it by making all images paths relative.

I tested the generated production site and the forestry admin, and they both seem to work.

You can apply the patch below by saving it as something.patch and then doing something like:
git am < something.patch

From 67ccb8e8822f9d4a89aebf9fd0ffb1272152b049 Mon Sep 17 00:00:00 2001
From: xananax <xananax@yelostudio.com>
Date: Sat, 29 Aug 2020 13:55:05 +0300
Subject: [PATCH] made paths relative

---
 content/posts/an-essay-on-walking.md        | 4 ++--
 content/posts/ne-te-quaesiveris-extra.md    | 4 ++--
 content/posts/on-the-geneology-of-morals.md | 2 +-
 content/posts/song-of-myself.md             | 4 ++--
 content/posts/sunflower-sutra.md            | 6 +++---
 5 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/content/posts/an-essay-on-walking.md b/content/posts/an-essay-on-walking.md
index ab8936e..0946f05 100644
--- a/content/posts/an-essay-on-walking.md
+++ b/content/posts/an-essay-on-walking.md
@@ -2,7 +2,7 @@
 date: 2019-07-31T22:43:31Z
 title: An Essay on Walking
 author: Robert Thoreau
-hero_image: "/content/images/heather-shevlin-3B_NrzTjajc-unsplash.jpg"
+hero_image: "../images/heather-shevlin-3B_NrzTjajc-unsplash.jpg"
 
 ---
 Then it is that I appreciate the beauty and the glory of architecture, which itself never turns in, but forever stands out and erect, keeping watch over the slumberers.
@@ -11,7 +11,7 @@ No doubt temperament, and, above all, age, have a good deal to do with it. As a
 
 But the walking of which I speak has nothing in it akin to taking exercise, as it is called, as the sick take medicine at stated hours,–as the swinging of dumb-bells or chairs; but is itself the enterprise and adventure of the day. If you would get exercise, go in search of the springs of life. Think of a man’s swinging dumb-bells for his health, when those springs are bubbling up in far-off pastures unsought by him!
 
-![](/content/images/kunj-parekh-H69EgivmCjE-unsplash.jpg)
+![](../images/kunj-parekh-H69EgivmCjE-unsplash.jpg)
 
 Moreover, you must walk like a camel, which is said to be the only beast which ruminates when walking. When a traveller asked Wordsworth’s servant to show him her master’s study, she answered, “Here is his library, but his study is out of doors.
 
diff --git a/content/posts/ne-te-quaesiveris-extra.md b/content/posts/ne-te-quaesiveris-extra.md
index 826abed..f413799 100644
--- a/content/posts/ne-te-quaesiveris-extra.md
+++ b/content/posts/ne-te-quaesiveris-extra.md
@@ -2,7 +2,7 @@
 date: 2019-08-13T22:40:32Z
 title: Ne Te Quaesiveris Extra
 author: Ralph Waldo Emerson
-hero_image: "/content/images/pawel-czerwinski-8uZPynIu-rQ-unsplash.jpg"
+hero_image: "../images/pawel-czerwinski-8uZPynIu-rQ-unsplash.jpg"
 
 ---
 I read the other day some verses written by an eminent painter which were original and not conventional. The soul always hears an admonition in such lines, let the subject be what it may. The sentiment they instill is of more value than any thought they may contain. To believe your own thought, to believe that what is true for you in your private heart is true for all men, — that is genius.
@@ -13,7 +13,7 @@ Speak your latent conviction, and it shall be the universal sense; for the inmos
 
 Yet he dismisses without notice his thought, because it is his. In every work of genius we recognize our own rejected thoughts: they come back to us with a certain alienated majesty. Great works of art have no more affecting lesson for us than this. They teach us to abide by our spontaneous impression with good-humored inflexibility then most when the whole cry of voices is on the other side. Else, to-morrow a stranger will say with masterly good sense precisely what we have thought and felt all the time, and we shall be forced to take with shame our own opinion from another.
 
-![](/content/images/anomaly-oRskqiH7FNc-unsplash.jpg)
+![](../images/anomaly-oRskqiH7FNc-unsplash.jpg)
 
 There is a time in every man’s education when he arrives at the conviction that envy is ignorance; that imitation is suicide; that he must take himself for better, for worse, as his portion; that though the wide universe is full of good, no kernel of nourishing corn can come to him but through his toil bestowed on that plot of ground which is given to him to till. The power which resides in him is new in nature, and none but he knows what that is which he can do, nor does he know until he has tried.
 
diff --git a/content/posts/on-the-geneology-of-morals.md b/content/posts/on-the-geneology-of-morals.md
index b5660db..3a4afad 100644
--- a/content/posts/on-the-geneology-of-morals.md
+++ b/content/posts/on-the-geneology-of-morals.md
@@ -13,7 +13,7 @@ So all respect to the good spirits that may govern in these historians of morali
 
 We see right away that this initial derivation already contains all the typical characteristics of the idiosyncrasies of English psychologists—we have “usefulness,” “forgetting,” “habit,” and finally “error,” all as the foundation for an evaluation in which the higher man up to this time has taken pride, as if it were a sort of privilege of men generally. This pride should be humbled, this evaluation of worth emptied of value. Has that been achieved?
 
-![](/content/images/ruslan-bardash-g83y6do219w-unsplash.jpg)
+![](../images/ruslan-bardash-g83y6do219w-unsplash.jpg)
 
 Now, first of all, it’s obvious to me that from this theory the origin of the idea “good” has been sought for and established in the wrong place: the judgment “good” did not move here from those to whom “goodness” was shown! It is much more that case that the “good people” themselves, that is, the noble, powerful, higher-ranking and higher-thinking people felt and set themselves and their actions up as good, that is to say, of the first rank, in contrast to everything low, low-minded, common, and vulgar. From this pathos of distance they first arrogated to themselves the right to create values, to stamp out the names for values. What did they care about usefulness!
 
diff --git a/content/posts/song-of-myself.md b/content/posts/song-of-myself.md
index 470ca62..0713192 100644
--- a/content/posts/song-of-myself.md
+++ b/content/posts/song-of-myself.md
@@ -2,7 +2,7 @@
 date: 2019-07-22T22:44:38Z
 title: Song of Myself
 author: Ralph Waldo Emerson
-hero_image: "/content/images/ren-ran-bBiuSdck8tU-unsplash.jpg"
+hero_image: "../images/ren-ran-bBiuSdck8tU-unsplash.jpg"
 
 ---
 I have heard what the talkers were talking, the talk of the  
@@ -18,7 +18,7 @@ Urge and urge and urge, Always the procreant urge of the world.
 
 Clear and sweet is my soul, and clear and sweet is all that is not my soul.
 
-![](/content/images/igor-son-FV_PxCqgtwc-unsplash.jpg)
+![](../images/igor-son-FV_PxCqgtwc-unsplash.jpg)
 
 Lack one lacks both, and the unseen is proved by the seen,  
  Till that becomes unseen and receives proof in its turn.
diff --git a/content/posts/sunflower-sutra.md b/content/posts/sunflower-sutra.md
index 51eb8c8..7552562 100644
--- a/content/posts/sunflower-sutra.md
+++ b/content/posts/sunflower-sutra.md
@@ -2,14 +2,14 @@
 date: 2019-08-08T22:42:09.000+00:00
 title: Sunflower Sutra
 author: Allen Ginsberg
-hero_image: "/content/images/adrien-olichon--aOsCcTJXWY-unsplash.jpg"
+hero_image: "../images/adrien-olichon--aOsCcTJXWY-unsplash.jpg"
 
 ---
 I walked on the banks of the tincan banana dock and sat down under the huge shade of a Southern Pacific locomotive to look for the sunset over the box house hills and cry.
 
 Jack Kerouac sat beside me on a busted rusty iron pole, companion, we thought the same thoughts of the soul, bleak and blue and sad-eyed, surrounded by the gnarled steel roots of trees of machinery.
 
-![](/content/images/elcarito-CRn-_80z4SE-unsplash.jpg)
+![](../images/elcarito-CRn-_80z4SE-unsplash.jpg)
 
 The only water on the river mirrored the red sky, sun sank on top of final Frisco peaks, no fish in that stream, no hermit in those mounts, just ourselves rheumy-eyed and hung-over like old bums on the riverbank, tired and wily.
 
@@ -29,7 +29,7 @@ leaves stuck out like arms out of the stem, gestures from the sawdust root, brok
 
 Unholy battered old thing you were, my sunflower O my soul, I loved you then!
 
-![](/content/images/francesco-mazzoli-0xh3QPqcfKM-unsplash.jpg)
+![](../images/francesco-mazzoli-0xh3QPqcfKM-unsplash.jpg)
 
 The grime was no man’s grime but death and human locomotives,
 
-- 
2.27.0.windows.1

Unrelated, but there's an error in blog.js on line 47. The url is relative. Add a / at the start of the url

- <Link to={`blog/${nextSlug}`} className={blogTemplateStyles.footer__next}>
+<Link to={`/blog/${nextSlug}`} className={blogTemplateStyles.footer__next}>

I can submit a PR with the above if you want.

@LB22
Copy link

LB22 commented Sep 12, 2020

Because of this issue being fixed by doing the changes @Xananax mentioned, there is a problem generating new posts.

When making a blog post in forestry.io, gatsby generates the content/posts/my-post.md file with this line hero_image: "/content/images/my-image.jpg"

This is not a problem live in production with netlify, only when trying to launch the same code locally using gatsby develop. (See image below)

How can we change so that the file is generated saying hero_image: "../images/my-image.jpg" instead of hero_image: "/content/images/my-image.jpg"? Hopefully without this causing a problem in production?

Edit: It seems like changing the dir to "../images/my-image.jpg" works fine in production.

If the content/posts/my-post.md file contains hero_image: "/content/images/my-image.jpg" it throws the error in the picture. If I change it to hero_image: "../images/my-image.jpg" and try to run gatsby develop again, it works fine.

error

@Xananax
Copy link

Xananax commented Sep 12, 2020

Indeed, re-writing the URLs to be relative works when running the site locally, and also works when deploying. There's a module, gatsby-remark-normalize-paths that this forestry theme uses, which makes absolute paths work. And there's gatsby-remark-relative-images, also used by the theme, which makes relative paths work.

in theory, both relative and absolute paths should work. I am not sure why they don't locally, but I guess it's fine as long as you use Forestry to change your blog or remember to make all your paths relative before running the site locally

@pvaladez
Copy link

pvaladez commented Oct 16, 2020

@Xananax - I recently upgraded gatsby-remark-relative-images to version 2 on my fork and I found that I needed to move gatsby-remark-normalize-paths before gatsby-remark-relative-images in gatsby-config.js on Line 59.

Then I found that I could actually remove gatsby-remark-relative-images all together and it still works. Both gatsby-remark-relative-images and gatsby-remark-normalize-paths sound like they do the same thing according to their descriptions, so I'm not sure how they are different or why we would need both.

Perhaps moving gatsby-remark-normalize-paths or removing gatsby-remark-relative-images in gatsby-config.js would fix the problems mentioned.

When I first started working with this repo, I tried to run it with Windows nodeJS and I found that I got the same "String" has no subfields. error. But I found that I didn't have this problem on macOS or Linux, so I gave up on using Node natively in Windows. I'll have to test again later if this is related.

Last thing- there is a mention of this same "String" has no subfields. error and how to fix it, but I haven't worked out how to fix it in our case here.

@pvaladez
Copy link

pvaladez commented Oct 16, 2020

@Xananax - well nevermind I tried all that and it didn't work with native Windows nodeJS. I definitely recommend using WSL2 Ubuntu with Windows... not having this problem with Ubuntu or MacOS. I recommend WSL2 over WLS1 because I was having a bunch of annoying "EACCESS" errors with version 1... you can fix it by telling vscode to stop watching files, but I didn't want to do that. Only caveat to WSL2 is that it is VERY slow when it comes to reading files from the Windows filesystem... to avoid this slowness, just create your project folders inside the WSL filesystem located at \\wsl$

More info: https://www.gatsbyjs.com/docs/gatsby-on-linux/#windows-subsystem-linux-wsl
I had trouble with n-install on my Ubuntu instance, so I installed nvm instead and haven't had any real issues.

@ma-bourassa
Copy link

Is there a way to fix this problem for Windows without wsl ?

@nguyen-michael
Copy link

With regards to Forestry.io, I have success changing the public path in the CMS settings to "../images" . This will append the relative path to all uploaded images and then apply them to the Site. Be cautious, as the CMS will append this to all uploaded images, so make sure you have your files structured to use this in that manner.

@RebootGG
Copy link

Still no update on this. This is sad, as this is the only showcased Gatsby starter with Forestry

@nguyen-michael
Copy link

Still no update on this. This is sad, as this is the only showcased Gatsby starter with Forestry

@RebootGG

See my note about about public_path, and another previous note about linking relative paths in the Markdown files.

What's happening is that the image isn't being found by the graphql query. So you need to make the paths relative.

It's been working fine for me.

@RebootGG
Copy link

Still no update on this. This is sad, as this is the only showcased Gatsby starter with Forestry

@RebootGG

See my note about about public_path, and another previous note about linking relative paths in the Markdown files.

What's happening is that the image isn't being found by the graphql query. So you need to make the paths relative.

It's been working fine for me.

Thanks Michael ! I didn't understand I had to modify the .md files as well. It works fine for me too. I have some warnings in my IDE about the paths now, but at least I can finally do some work.

@jonatr35
Copy link

If anyone gets here and are already using relative path, this error will also show up if you have image files that have caps in the filename. I had to lowercase all the img filenames to get it to work properly.

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

8 participants