Urigo/graphql-cli

Parse configuration → Cannot convert undefined or null to object

fnduister opened this issue · 5 comments

Hi,
When trying to convert a simple graphql schema, i'm getting this error
× Parse configuration
→ Cannot convert undefined or null to object

Steps to reproduce the behavior:

  1. create .graphql.yml with this content
schema: ./src/**/*.graphql
extensions:
  codegen:
    ./generated-backend.ts:
      plugins:
        - typescript
  1. npx graphql-cli@next init

  2. choose backend only, no generation, typescript

  3. yarn graphql codegen

  4. See error: Parse configuration → Cannot convert undefined or null to object

Expected behavior
should generation typescipt types

Screenshots
graphql
graphql1

Versions (please complete the following information):

  • OS: windows10
  • graphql-cli: 4.0.1-beta.2

I think this is due to missing required documents section in config.
At least this is what it was for myself
It seems like validation issue in config.

Did this solved the issue. Feel free to reopen if needed.

olso commented

This worked for me

schema: http://localhost:8081/graphql
extensions:
  codegen:
    generates:
      ./schema.graphql:
        - schema-ast
      src/client/types.ts:
        - typescript

I also use relay

"relay": "relay-compiler --src src --schema ./schema.graphql --extensions ts tsx --artifactDirectory src/__generated__ --language typescript",
    "syncgql": "run-s schema relay",
    "schema": "graphql codegen",

@olso , Thank you. It also worked for me.

olso commented

@arjun-kava Also if you have custom scalars, you can type them 🙂

schema: http://localhost:8081/graphql

config:
  scalars:
    DateTime: string
    Money: string

generates:
  src/types/Generated.ts:
    - typescript