redwood: [Bug]: GraphiQL headers file not gitignored by default, and causes crash if you do ignore it
What’s not working?
As per the documentation:
A generateGraphiQLHeader file will be created in your api/lib folder and included in your gitignore. You can edit this file to customize your header. The function in the file is passed into your createGraphQLHandler and only called in dev.
The file is not automatically added to gitignore, but if you manually add it, because the generateGraphiQLHeader
file is import
ed by api/functions/graphql
, it causes a crash on CI deployment because it’s trying to import a file that doesn’t exist.
How do we reproduce the bug?
yarn rw setup graphiql dbAuth --id <user id>
- Add the
generateGraphiQLHeader
file to gitignore - Try to deploy through CI/re-clone and try to run the app
Are you interested in working on this?
- I’m interested in working on this
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 2
- Comments: 18 (10 by maintainers)
Hi, @alicelovescake @dthyresson,
I’d like to share what I did and think it might be a workaround. This is specific to Netlify though.
In graphql.ts, we can do something like this
And also in netlify.toml. I added this to tell Netlify not to look for a specific inline dependency (in this case the non exisitance file)
It works on both local and Netlify builds. So I guess I don’t have to manually remove generateGraphiQLHeader now.
Thanks
ps: perhaps the try-catch is unnecessary.
@alicelovescake Let’s talk about improving the deploy experience seen here. Thanks!
I received some context on Discord.
I believe the issue happens if you add the
generateGraphiQLHeader
in the graphql function and deploy, say to Netlify.Because the file is ignored and the function needs it, builds can fail.
Perhaps a pattern like:
can be used.