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

Schema does not update without restarting 'gatsby develop' #42

Open
huntercaron opened this issue Sep 2, 2020 · 10 comments
Open

Schema does not update without restarting 'gatsby develop' #42

huntercaron opened this issue Sep 2, 2020 · 10 comments

Comments

@huntercaron
Copy link

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

@danielmahon
Copy link
Owner

@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)

@huntercaron
Copy link
Author

@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!

@danielmahon
Copy link
Owner

@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.

@huntercaron
Copy link
Author

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

@danielmahon
Copy link
Owner

@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"

@huntercaron
Copy link
Author

@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?

@huntercaron huntercaron reopened this Sep 3, 2020
@kalebheitzman
Copy link

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.

@alexford
Copy link

alexford commented Feb 4, 2021

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

@huntercaron
Copy link
Author

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

@AmplifiedHuman
Copy link

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

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

5 participants