Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Options getting forwarded to graphql-cli cmd #169

Open
donovanhiland opened this issue Feb 27, 2018 · 5 comments
Open

Options getting forwarded to graphql-cli cmd #169

donovanhiland opened this issue Feb 27, 2018 · 5 comments

Comments

@donovanhiland
Copy link

  • nps version: 5.8.0
  • node version: 9.4.0
  • npm version: 5.6.0

Scripts file (or at least the relevant bits):

{
    scripts: {
        introspection: 'graphql get-schema'
    }
}

The command executed:

yarn start introspection

The output:

yarn run v1.3.2
$ nps introspection
nps is executing `introspection` : graphql get-schema
graphql get-schema

Download schema from endpoint

Options:
  --dotenv        Path to .env file                                     [string]
  -p, --project   Project name                                          [string]
  --watch, -w     watch server for schema changes and update local schema
                                                                       [boolean]
  --endpoint, -e  Endpoint name or URL                                  [string]
  --json, -j      Output as JSON                                       [boolean]
  --output, -o    Output file name                                      [string]
  --console, -c   Output to console                             [default: false]
  --insecure, -i  Allow insecure (self-signed) certificates            [boolean]
  --all           Get schema for all projects and all endpoints        [boolean]
  --header        Header to use for downloading (with endpoint URL)     [string]
  -h, --help      Show help                                            [boolean]
  -v, --version   Show version number                                  [boolean]

Unknown argument: endpointName
✨  Done in 1.47s.

Problem description:

When running graphql get-schema with nps, an endpointName options gets passed through which fails validation in graphql-cli. Running the same command from package.json scripts works as expected. I'm not sure where the issue can be resolved from, if either, so I think I'm going to open an issue in both and see if something can be resolved. Happy to help how I can.

@kentcdodds
Copy link
Collaborator

Huh... No idea why an endpointName would magically appear here. You could try diving into your node_modules to see if that helps...

Let us know what you come up with.

@donovanhiland
Copy link
Author

donovanhiland commented Feb 27, 2018

Ok so the magically appearing endpointName isn't so magical after all. I have an env var GRAPHQL_CONFIG_ENDPOINT_NAME which yargs is parsing and passing as an argument with something like .env('GRAPHQL_CONFIG'). It's not expecting an endpointName argument and so fails on yargs.strict().

In my package.json:

{
  "scripts": {
    "start": "nps",
    "introspection": "graphql get-schema"
  }
}

My package-scripts.js

{
    scripts: {
        introspection: 'graphql get-schema',
        npmIntrospection: 'yarn run introspection'
    }
}

yarn start introspection - fails
yarn start npmIntrospection - fails
yarn run introspection - works

I'm curious as to why running it through nps in any fashion fails, but directly running the npm script works.

@kentcdodds
Copy link
Collaborator

I have no idea why this is happening though:

I have an env var GRAPHQL_CONFIG_ENDPOINT_NAME which yargs is parsing and passing as an argument with something like .env('GRAPHQL_CONFIG')

and

I'm curious as to why running it through nps in any fashion fails, but directly running the npm script works.

I'm also curious. I'm really sorry @donovanhiland, I just have very limited time to dedicate to this package so I can't be a lot of help to you here :-/

@donovanhiland
Copy link
Author

I totally understand! I'll document any other findings here in case someone else runs into the same issue.

@donovanhiland
Copy link
Author

Workaround: Urigo/graphql-cli#228 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants