graphql-code-generator
graphql-code-generator copied to clipboard
Failed to load schema [bug]
Describe the bug
I am unable to create typescript types from graphql schema. Discussed here discuss
Also, I found out that, it works fine on stackbliztt if i run below command
npm run codegen
Your Example Website or App
https://github.com/nirmaanlabs/bug
Steps to Reproduce the Bug or Issue
npm i
npm run codegen
Expected behavior
I should get a file with generated types
Screenshots or Videos
video codegen failed to read schema.zip
Platform
-
OS: [Windows]
-
NodeJS: [16.16.0]
-
graphql
version: [16.5.0] -
"@graphql-codegen/cli": "^2.9.1", "@graphql-codegen/typed-document-node": "^2.3.2", "@graphql-codegen/typescript": "^2.7.2", "@graphql-codegen/typescript-operations": "^2.5.2",
Codegen Config File
schema: schema.graphql generates: ./src/generated.ts: plugins: - typescript - typescript-operations - typed-document-node
Additional context
Coming here from the discussion
We need to have a clear reproduction that shows the issue on that StackBlitz example. Otherwise we cannot help you, sorry.
We need to have a clear reproduction that shows the issue on that StackBlitz example. Otherwise, we cannot help you, sorry.
Hey, @ardatan I have provided the video and GitHub link to my repo, is that not sufficient? So it does not work on my local machine and works on stackblitzz
Is there any way, I can see some more insightful logs of why my schema load command failed? As of now it just tells you failed to load schema, and it does not tell you why did it fail.
update: after console logging found this
graphql-code-generator fails to read the schema.graphql
file if it is in utf 16 le encoding. All my schema files are automatically generated by apollo rover cli. Read about this issue here.
Is there any flag in cli
where user can inspect any error, in verbose? I had to console log in my node_modules
folder. This verbose flag can potentially save some time while debugging
I agree, it would be helpful if there was some more information about the error.
Saw similar and had to do much the same, the verbose and debug flags don't emit the error. Is there a bug in the output code?
if your GraphQL server is up and running, you can use the following to print the schema to a file:
npm install -g graphqurl
gq < graphql-endpoint > --introspect > schema.graphql
# if your graphql endpoint requires authentication:
gq < graphql-endpoint > -H "Authorization: Bearer <token>" --introspect > schema.graphql
Let me know if it helps you out