Urigo/graphql-cli

TypeError: Cannot read property 'definitions' of undefined

6axter82 opened this issue · 4 comments

I have created a project using "npx graphql-cli@next init"
choose the fullstack version and go through steps in README.md

Running "yarn graphql codegen"

I am getting the following error:

./client/src/generated-types.tsx
TypeError: Cannot read property 'definitions' of undefined

If anyone has any solution?

@6axter82 I have tried to replicate this issue.
Can you tell us if you have your schema and client side queries generate. Is client/graphql folder created with some content?

I believe it has something to do with the refactor of loadDocuments in the @graphql-codegen/cli project, from property name content > document. It seems like the released version 4.0.1-beta.0 of @test-graphql-cli/codegen contains an older version 1.11.1 of @graphql-codegen/cli. When this is paired with version 1.12.2 of for example @graphql-codegen/typescript-operations it breaks with the above error.

The problem is two fold. First being an error, understandably, from the consumer installing newer version of codegen plugins than the hidden @graphql-codegen/cli version. The second being refactoring of a seemingly breaking change treated as a minor version update.

Solution seems to be to either wait for graphql-cli@4.0.1-beta.1 to drop or to downgrade plugins like @graphql-codegen/typescript-operations to 1.11.1.

Hope this helps, took me most of the day to figure out as the init command didn't seem to be able to generate when codegen was selected.

This must be fixed in v4.0.1-beta.2

radar commented

I fixed this issue by bumping all the @graphql-codegen packages:

Before:

    "@graphql-codegen/add": "1.4.0",
    "@graphql-codegen/cli": "1.4.0",
    "@graphql-codegen/fragment-matcher": "1.4.0",
    "@graphql-codegen/typescript": "1.4.0",
    "@graphql-codegen/typescript-operations": "1.4.0",
    "@graphql-codegen/typescript-react-apollo": "1.4.0",

After:

    "@graphql-codegen/add": "1.17.8",
    "@graphql-codegen/cli": "1.17.8",
    "@graphql-codegen/fragment-matcher": "1.17.8",
    "@graphql-codegen/typescript": "1.17.9",
    "@graphql-codegen/typescript-operations": "1.17.8",
    "@graphql-codegen/typescript-react-apollo": "2.0.6",