-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Error loading schema from URL or GraphQL Endpoint #8012
Comments
I just ran into this problem too. I edited
I'm not sure where in the code exactly it's generating this request, but it does seem to be trying to do a HTTP GET with a body, which is not permitted. |
Faced with the same issue, reinstalled packages in project and got the same error. After reverting to old package-lock.json it works good, so I think there is a bug in a minor version of one of packages |
I believe I also tried with version 2.0.0 of @graphql-codegen/cli and the problem persisted which would point to a dependency issue but I might have missed something. Tomorrow I'll do some further testing and debugging. Thanks for your feedback! |
I just found the problem. It's in the
This has the effect of reverting the dependent version from 5.6.0 (broken) to 5.5.1 (previous release, working), without leaving it in your package.json. 5.5.1 is the previous version (released 18 days ago), it only broke in the version following this (5.6.0) released 11 hours ago. After doing this I was able to run the code generator again successfully. |
@edramos-97 can you please try latest version of |
Hi @saihaj that's the one I was using initially and the same as in the bug report (Platform section). I only tried to downgrade |
Experiencing the exact same issue, but the undici reinstall does not work for me as you suggested @adam-nielsen. I have graphql-codegen running in multiple projects, but this new project is the only one I'm experiencing issues with. Not sure how to resolve it,as I've tried to force installing the same versions of graphql-codegen that I have in my other projects already EDIT: undici forced to |
That worked for me too! @franzwilhelm if you're using
|
@tylermenezes thank you it worked! 🎉 I only added it to the sub-package of my project. So.. To yarn workspace users: you need to add resolutions to the root package.json as well |
So it is broken in downstream dependency. |
For people using NPM, you can use an It requires npm 8.3 or later. Mine looks like this: {
...
"dependencies": ...
"devDependencies": ...
"overrides": {
"undici": "5.5.1"
}
} |
I confirm it works |
Hi! You can find a detailed explanation there. Thanks for your patience! |
I ran |
Describe the bug
When attempting to run the code generator with a schema variable that is a URL it fail with the following error:
Failed to load schema from http://my-graphql-api.com/graphql: Request with GET/HEAD method cannot have body.
Stack Trace:
Your Example Website or App
https://github.com/edramos-97/graphql-code-generator-issue-sandbox-template
Steps to Reproduce the Bug or Issue
Execute
npm install
followed bynpm run generate
See error "Failed to load schema from http://my-graphql-api.com/graphql: Request with GET/HEAD method cannot have body."
Expected behavior
As a User, I expected the code generator to support loading the schema from a URL/GraphQL endpoint but I'm seeing a fatal error that prevent the schema from being loaded
Screenshots or Videos
No response
Platform
npm tree as of reporting:
graphql-codegen-issue-template@1.0.0
├── @graphql-codegen/add@3.1.1
├── @graphql-codegen/cli@2.6.4
├── @graphql-codegen/typescript-operations@2.4.1
├── @graphql-codegen/typescript@2.5.0
└── graphql@16.5.0
Codegen Config File
schema: http://my-graphql-api.com/graphql
documents: './src/**/*.tsx'
generates:
./graphql/generated.ts:
plugins:
- typescript
- typescript-operations
- typescript-react-query
config:
fetcher: fetch
# Copied from the guide https://www.graphql-code-generator.com/docs/guides/react
Additional context
No response
The text was updated successfully, but these errors were encountered: