graphql-code-generator icon indicating copy to clipboard operation
graphql-code-generator copied to clipboard

Could generate from local `.schema` or local `introspection.json` file.

Open vsDizzy opened this issue 2 years ago • 2 comments

Describe the bug

If I split the generations into two steps:

  1. Download shema.
  2. 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

  1. npm i
  2. npm run get-schema
  3. npm start

Expected behavior

There should be no error.

Screenshots or Videos

image

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.

vsDizzy avatar Sep 06 '22 05:09 vsDizzy

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?

ardatan avatar Sep 06 '22 15:09 ardatan

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.

vsDizzy avatar Sep 06 '22 18:09 vsDizzy