Urigo / graphql-cli

📟 Command line tool for common GraphQL development workflows
https://graphql-cli.com
MIT License
2k stars 113 forks source link

Unknown argument error for plugins #60

Closed loremaps closed 6 years ago

loremaps commented 6 years ago

I just tried to install graphql-cli with a plugin (codegen but it is the same with voyager)

npm i -g graphql-cli graphql-cli-codegen

graphql -v reports 2.0.9 and seems to works ok. However, I cannot call the plugin: graphql codegen shows the error:

Unknown argument: codegen

Am I missing something here? Thanks

schickling commented 6 years ago

Is anybody else experiencing this problem?

@loremaps would be good to know more about your setup: OS, Node version, NPM version

loremaps commented 6 years ago

OS: Ubuntu 16.04 LTS npm: 5.5.1 node: 8.9.3

I also reproduced it in another machine with

OS: Ubuntu 16.04 LTS npm: 5.6.0 node: 8.9.3

loremaps commented 6 years ago

It seems that the problem is caused by the jonschlijonschlinkert/npm-paths dependency; which does not return the correct paths for my case. If I hardcode my global npm path here: https://github.com/graphql-cli/graphql-cli/blob/be73eec100749f07dcfe2ad978ee5dcea195b1fc/src/index.ts#L29

The error is no longer reported.

Specifically, the first path returned by the npmPaths() is: /home/username/tests/graphql-cli/~/.npm-global/lib/node_modules but in my case the correct path is: /home/username/.npm-global/lib/node_modules

schickling commented 6 years ago

Thanks for further digging into this @loremaps. Would be great if you can figure out a solution that works also in your case that we can introduce as a fix in graphql-cli.

loremaps commented 6 years ago

Fixed in the latest release 2.1.3. Thanks @schickling