danielmahon/gatsby-remark-relative-images

Schema does not update without restarting 'gatsby develop'

huntercaron opened this issue · 10 comments

Screenshot 2020-09-02 at 13 12 33

When editing images in Frontmatter while in development mode, the GraphQL queries break with the Field "gallery_images" must not have a selection since type "[String]" has no subfields. until you restart gatsby develop.

You can repro by commenting out an image in a list like this while running development
Screenshot 2020-09-02 at 13 42 00

@huntercaron I am unable to reproduce, FYI I use gatsby-starter-netlify-cms for compatibility testing.

Have you defined a non-empty gallery_images in each markdown file for that type? Conditional fields may require you to add your own typings.

Also is /assets your static folder? If so you need to define that in the plugin options and reference the images as an absolute path from the folder (ie: /images (4).jpeg)

@danielmahon thanks for digging into it!

I've been using this for forestry.io (works great btw except for this hiccup), assets is my folder within static similar to images in the example.

It's pretty odd actually, nothing was fixing it except for manually refreshing the schema. Tried yarn clean a bunch of times, etc and nothing fixed it - then I gave up & came back a few hours and everything seems fine 🤷
.
I'll close this for now until I'm able to find a better reproduction path / if it happens again. Thanks!

@huntercaron One thing Ive noticed while developing this plugin is the gatsby develop cache seems to be annoyingly inconsistent. Even with running gatsby clean before each start it wouldn't always produce the same results. I think part of it is the gatsby develop process sometimes hangs around for a bit after exit and seems to cause weird behaviour when starting again (duplicating process? reconnecting to existing one?) I'm not really sure as I just started working with Gatsby again after a few years. So its also possible I'm doing something "race condition-y" in the plugin but haven't found it yet. Let me know if you run into more issues.

Ah yeah that sounds just like what I've been experiencing. It's also my first time using Gatsby in a few years, I thought remembered it being more stable than this.

What weird now is that seems to be working locally but broken in the forestry preview server (essentially they just run gatsby develop on a server). I tried looking to see if there was a way to force reload the schema but only found a server endpoint that would feel pretty hacky to ping from the node process. Not sure what to try next honestly
Screenshot 2020-09-02 at 17 46 31

@huntercaron do you need indentation in-front of your list items under gallery_images? I just noticed they are inline with the parent, and they shouldn't be. YAML cares about stuff like that.

gallery_images:
- "/assets/images (1).jpeg"
- "/assets/images (2).jpeg"
- "/assets/images (3).jpeg"

should be

gallery_images:
  - "/assets/images (1).jpeg"
  - "/assets/images (2).jpeg"
  - "/assets/images (3).jpeg"

@danielmahon I thought it would be easier to show the behaviour in a gif, I think I've found a pretty solid reproduction.

You can see it works fine until the data hot-reloads (via commenting a line out), then it breaks. But I've found that it doesn't break when a different markdown file in the content folder exists. When I change the file extension of the 'contact' file to just a txt file, everything works as expected.

relativebug

Repo for the reproduction here: https://github.com/huntercaron/relative-bug
and the content folder in question: https://github.com/huntercaron/relative-bug/tree/master/src/content

Any ideas what might be going on?

You can see it works fine until the data hot-reloads (via commenting a line out), then it breaks.

I'm having this same exact issue. I'm using it within a theme if that matters.

I am also seeing this. In my case saving the markdown file in question again clears the error.

It looks like the schema isn't generated properly on the first hot-reload after changing the file. A second hot-reload (triggered just by saving the file again, not actually changing anything) clears it. I don't have to restart the process

It doesn't matter what I change in the file — a non-image field or the content itself. Just any kind of change results in a bad schema

For context I was never able to fix this, and ended up moving my site to nextjs (not the solution for everyone of course)

Having the same issue as well, it looks like gatsby-remark-relative-images does not convert the frontmatter images to actual images after hot reloading