graphql-code-generator
graphql-code-generator copied to clipboard
Could generate from local `.schema` or local `introspection.json` file.
Describe the bug
If I split the generations into two steps:
- Download shema.
- Generate types from local
.schema
file.
Then the generation fails:
✖
Failed to load schema from schema.graphql,introspection.json:
Unable to find any GraphQL type definitions for the following pointers:
- schema.graphql
,
- introspection.json
Error:
Unable to find any GraphQL type definitions for the following pointers:
- schema.graphql
,
- introspection.json
at prepareResult (/workspaces/!gql/node_modules/@graphql-tools/load/cjs/load-typedefs.js:75:15)
at loadTypedefs (/workspaces/!gql/node_modules/@graphql-tools/load/cjs/load-typedefs.js:39:12)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
However it works when https schema is specified.
Your Example Website or App
https://github.com/vsDizzy/gql-codegen-bug
Steps to Reproduce the Bug or Issue
- npm i
- npm run get-schema
- npm start
Expected behavior
There should be no error.
Screenshots or Videos
Platform
- OS: docker
- NodeJS: 16
- "@graphql-codegen/cli": "^2.12.0", "@graphql-codegen/introspection": "^2.2.1", "@graphql-codegen/schema-ast": "^2.5.1", "@graphql-codegen/typescript": "^2.7.3"
Codegen Config File
schema:
- schema.graphql
- introspection.json
generates:
types.ts:
plugins:
- typescript
Additional context
This is also not working for shema downloaded with apollo client:download-schema
.
I don't see any errors here; https://codesandbox.io/p/github/vsDizzy/gql-codegen-bug/csb-lzb4fl/draft/misty-cloud?file=%2Fget-schema.codegen.yml&selection=%5B%7B%22endColumn%22%3A1%2C%22endLineNumber%22%3A16%2C%22startColumn%22%3A1%2C%22startLineNumber%22%3A16%7D%5D Could you reproduce it on CodeSandbox or StackBlitz using our template?
It works online and under docker run -it node:16 sh
But it fails under remote-containers or locally on Windows.
There is .devcontainer
folder in the example repo above. You can use remote containers
extension in VS code.