Urigo / graphql-cli

📟 Command line tool for common GraphQL development workflows

Home Page:https://graphql-cli.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

get-schema --json fails with "Cannot read property 'types' of undefined"

terkiterje opened this issue · comments

Describe the bug
The documentation from get-schema --help lists

  --json, -j      Output as JSON                                       [boolean]

When using the --json option for get-schema with version 3.0.3, it always fails with the same error "Cannot read property 'types' of undefined"

To Reproduce
Steps to reproduce the behavior:

yarn run gql get-schema --json --endpoint https://graphql.brandfolder.com/graphql --output schema.json

Here I randomly selected the first public endpoint I could find from google search "public graphql endpoint", since the problem seems to be unrelated to the endpoint.

Expected behavior
A schema.json to be created without errors, like in version 2.16.0

Versions:

  • graphql-cli: [3.0.3]

Additional context
The works with 2.16.0 version. A possible mitigation seems to be just dropping --json since the schema contains the JSON needed (but this also includes other unwanted stuff in the schema, I guess)

I have the same issue.

I can confirm this is still an issue.
Ommiting the --json flag still works great though.

Working : graphql get-schema --endpoint http://localhost:3000/graphql --output schema.graphql

Not working: graphql get-schema --json --endpoint http://localhost:3000/graphql --output schema.json

I am having the same issue, any fixes for this?

@mislavlukach omitting the json flag worked for me while ensuring that the file name (output flag) has a json extension.
e.g graphql get-schema --endpoint="https://yourendpoint.dev/graphiql" --output="schema.json"

We've just released a new alpha version channel for GraphQL CLI - 4.0.0-alpha.XXX!

We've changed the get-schema command to use GraphQL Code Generator plugin of GraphQL CLI with the Codegen's schema-ast plugin.

Checkout new instructions in the migration guide and let us know your feedback during that alpha period!

Could you check if that runs as intended?

Feel free to contact us by opening a new issue or joining our Discord channel;
https://discord.gg/xud7bH

I've posted the wrong Discord link, this is the correct one: https://discord.gg/xud7bH9