-
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
Introspection fails to load schema from server #7934
Comments
I'm facing the same problem and have not found a solution yet :-/ |
I found out something, when I'm not using my local graphql server but instead a public one like https://api.spacex.land/graphql it can fetch the schema. So apparently the problem in this case is on my side. I'm using laravel and laravel-lighthouse. Edit: Another update: I logged the introspection query
Running this query with Insomnia is working perfectly fine… |
I found a workaround by just fetching and saving my schema via Note: There is no export for const { getIntrospectionQuery } = require('graphql')
// In fetch method:
{ query: getIntrospectionQuery() } |
In my environment, the same problem occurs because the server does not return a rel: nodejs/undici#1414 |
another way for laravel and local server (http://127.0.0.1:8000/graphql) is to force response header with Content Length
$response = $kernel->handle(
$request = Request::capture()
);
$response->header('Content-Length', strlen($response->getContent()))->send(); PS or create custom middleware and register it for lighthouse (the right way) |
I found that the above Laravel work-around above breaks OPTIONS request from browser, but it did work for generating :) Below is a middleware, which can be added to App/Http/Middlewares and put into lighthouse middlewares config array. https://gist.github.com/LiamKarlMitchell/18f1e43ae6b772864d1b6a6ec1f71ba9 Works for me for a temp work-around until this can be resolved upstream. |
@LiamKarlMitchell We noticed that same problem with OPTIONS request and Content-Length. We solved it likes this in $response = $kernel->handle(
$request = Request::capture()
);
// "Content-Length" header is not allowed in OPTIONS requests.
if (!$request->isMethod('options')) {
// To be able to run GraphQL codegen.
$response->header('Content-Length', strlen($response->getContent()));
}
$response->send(); |
@MarcusThe , that way more succinct nice! No fix at the time of writing in the client side nodejs/undici#1414 |
Describe the bug
I have installed the latest version of graphql-codegen and used the same config from another project to generate the types.
It works on the old project, but fails in the new one.
It seems to me that cross-undici-fetch dependency is the cause of the problems, I tried to override the version but I can't get it to work.
Old project uses:
New Project:
I can exclude the server as the source of problem, because introspection via phpstorm or from the old project works find.
To Reproduce
1.) Create a blank nextjs project
2.) Setup graphql codegen
3.) Create a codegen.yml that loads the schema from remote
4.) Execute codegen
Steps to reproduce the behavior:
The schema works fine its the fetch that fails.
Doesn't load the schema from the server.
codegen.yml
config file:Expected behavior
It should load the schema from the server and generate the types as it did.
Environment:
Additional context
The text was updated successfully, but these errors were encountered: