gatsby-plugin-graphql-component icon indicating copy to clipboard operation
gatsby-plugin-graphql-component copied to clipboard

Issues on production builds

Open jamesdbruner opened this issue 4 years ago • 7 comments

Maybe I'm doing something completely wrong but I couldn't get this plugin to work on a test project when I ran gatsby serve so I figured I'd poke around your docs and see if I could get your example working locally and it works fine if you only run gatsby develop but running gatsby build gives me this

ERROR #11321  PLUGIN

"gatsby-plugin-graphql-component" threw an error while running the onPreBuild lifecycle:

ENOENT: no such file or directory, open '/gatsby-plugin-graphql-component/examples/gatsby-plugin-graphql-component-default-example/public/page-data/sq/d/3596933046.json'

I don't get that exact same error on my test project. I get this:

Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object.

but I'm not doing anything crazy, just following the docs and I can't run gatsby serve :( Any insight would be much appreciated!

jamesdbruner avatar Dec 09 '20 21:12 jamesdbruner

Try to check out this issue: https://github.com/pristas-peter/gatsby-plugin-graphql-component/pull/2

Should be fixed in latest release

pristas-peter avatar Dec 10 '20 14:12 pristas-peter

@pristas-peter I've confirmed this morning that both the docs and my test project are on 0.2.4 which is the latest version, I even went into node_modules and made sure that in my test project the fs.readFile(path.join(directory, `public`, `page-data`, `sq`, `d`, `${value.hash}.json`), `utf-8`) fix is in there.

I also had a coworker pull down this repo and try to run the example and he also got that same error when running yarn build inside your example.

"gatsby-plugin-graphql-component" threw an error while running the onPreBuild lifecycle:

ENOENT: no such file or directory, open '/Users/michaelharvey/Documents/Projects/tests/gatsby-plugin-graphql-component/examples/gatsby-plugin-graphql-component-default-example/public/page-data/sq/d/3596933046.json'

I'm hoping that the issue with your example is the same as the issue with my test project.

jamesdbruner avatar Dec 10 '20 17:12 jamesdbruner

@pristas-peter Ahhh so I tried updating your examples gatsby version (I just did 2.24.47 because it's what I've been using in other projects) and now your example seems to work as I'd expect.

jamesdbruner avatar Dec 14 '20 17:12 jamesdbruner

@pristas-peter Sorry to keep blowing up your notifications. I created a reproduction repo for one of the issues I'm having https://github.com/jamesdbruner/graphql-component-test I've laid out the steps to take to reproduce the issue in the readme but essentially it's when I try to serve the component breaks, hard-refreshing fixes it and then refreshing again breaks it. It's very strange.

jamesdbruner avatar Dec 14 '20 18:12 jamesdbruner

Thanks for the repo, I am a little bit busy this week, but will surely have a look at it.

pristas-peter avatar Dec 15 '20 10:12 pristas-peter

@pristas-peter Any update on this?

jamesdbruner avatar Feb 10 '21 17:02 jamesdbruner

@pristas-peter any fix for this? I'm still getting this error on gatsby build

connorhinkson avatar Sep 14 '22 17:09 connorhinkson