Closed ksirrah13 closed 2 years ago
I haven't been able to determine why the plugin options are incomplete in these cases, but this is preventing us from being able to use gatsby v4 with our production graphql server.
My first guess would be the fact that buildSchema
plugin option is a function (which can't be serialized) and ending up in engine bundle as undefined
.
There are 2 ways to address it:
gatsby-source-graphql
to configure buildSchema
without the need of a function (for example allow string which would point to .graphql
file with schema to do what you are doing in https://github.com/ksirrah13/gatsby-bug-repro/blob/562642287457b14f75414d89a2c6bbf374627e69/gatsby-config.js#L22-L25 (unless this was quite simplified for repro and actual production version of this function is more involved)Also note that in gatsby-node.js if I set defer:false it will build successfully even with the broken graphql endpoint. This seems to be because it will skip Generating Rendering Engines and correctly use the createSchema function from the plugin in this case instead of incorrectly querying the graphql endpoint for the schema.
This problem seem to happen in engines so it make sense that getting rid of all DSG
or SSR
pages (which then cause skipping engines generation and validation) "fixes" it
Thank you @pieh for the suggestions. For the workaround suggested would you then recommend creating a local patched plugin of gatsby-source-graphql
to accept a string file path to the schema? Or is there a better approach to extending/modifying plugin functionality like this? Our use case is simple enough that this could work without a function call for createSchema
here.
Also, in case others have a similar situation I wanted to point out that even though we weren't using DSG or SSR pages, Gatsby v4 determined we needed to create the rendering engines because of an exported config
in storybook-addon-gatsby
, https://github.com/prismicio-community/storybook-addon-gatsby/blob/main/src/index.ts#L16. Removing this addon "fixes" this issue for now, however once we add any SSR or DSG pages I expect this issue will become a blocker again.
Hiya!
This issue has gone quiet. Spooky quiet. 👻
We get a lot of issues, so we currently close issues after 60 days of inactivity. It’s been at least 20 days since the last update here. If we missed this issue or if you want to keep it open, please reply here. As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!
Thanks for being a part of the Gatsby community! 💪💜
Hey again!
It’s been 60 days since anything happened on this issue, so our friendly neighborhood robot (that’s me!) is going to close it.
Please keep in mind that I’m only a robot, so if I’ve closed this issue in error, I’m HUMAN_EMOTION_SORRY
. Please feel free to comment on this issue or create a new one if you need anything else.
As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!
Thanks again for being part of the Gatsby community! 💪💜
Hello, this bug is still not resolved. Are you working on patches proposed by @pieh ?
For me it's funny. I had a SSR query in my page and when run npm run build
, I stuck in there, just remove SSR query and problem solved!
Preliminary Checks
Description
Similar to this issue https://github.com/gatsbyjs/gatsby/issues/24603 I am getting the following error when attempting to build after upgrading to Gatsby v4. This only happens when I am using a graphql endpoint that has introspection disabled (our prod endpoint). When using a staging endpoint which allows introspection this error does not occur.
The error thrown by the worker is
Source GraphQL API: HTTP error 400 Bad Request
Even though I have specified
createSchema
in the plugin options forgatsby-source-graphql
it still appears to be attempting to get the schema via introspection when evaluatingcreateSchemaCustomization
for the plugin.What I have noticed is that the plugin options available in
createSchemaCustomization
suddenly loses thecreateSchema
property when this method is being executed by a worker during theValidating Rendering Engines
step. All other times the plugin options seem complete and correctly include thecreateSchema
property.Because there is no value for
createSchema
one of these times, the plugin attempts to get the schema via introspection from the graphql endpoint duringcreateSchemaCustomization
, however the graphql endpoint doesn't allow introspection which results inSource GraphQL API: HTTP error 400 Bad Request
and the build fails. https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby-source-graphql/src/gatsby-node.js#L65I haven't been able to determine why the plugin options are incomplete in these cases, but this is preventing us from being able to use gatsby v4 with our production graphql server.
Reproduction Link
https://github.com/ksirrah13/gatsby-bug-repro.git
Steps to Reproduce
repro-create-schema-bug
npm install
andnpm run build
Note that in the repro I am using a broken graphql api link
https://rickandmortyapi.com/graphql_broken
. This is to mimic the behavior of using a graphql endpoint that doesn't have introspection enabled. I have reproduced this using our production endpoint without introspection (requires auth that I can't share for this repro), but you can substitute any other graphql endpoint here as long as it doesn't allow introspection to see the same issue.Also note that in
gatsby-node.js
if I setdefer:false
it will build successfully even with the broken graphql endpoint. This seems to be because it will skip Generating Rendering Engines and correctly use thecreateSchema
function from the plugin in this case instead of incorrectly querying the graphql endpoint for the schema.Expected Result
Successful build
Actual Result
Environment
Config Flags
No response