graphql-client icon indicating copy to clipboard operation
graphql-client copied to clipboard

introspect-schema does not work with header

Open Ten0 opened this issue 4 years ago • 2 comments

As per the documentation:

graphql-client introspect-schema --help
graphql-client-introspect-schema 0.9.0
Get the schema from a live GraphQL API. The schema is printed to stdout

USAGE:
    graphql-client introspect-schema [OPTIONS] <schema-location>

FLAGS:
    -h, --help       Prints help information
    -V, --version    Prints version information

OPTIONS:
        --authorization <authorization>    Set the contents of the Authorizaiton header
        --header <headers>...              Specify custom headers. --header 'X-Name: Value'
        --output <output>                  Where to write the JSON for the introspected schema

ARGS:
    <schema-location>    The URL of a GraphQL endpoint to introspect

I understand this should work:

> graphql-client introspect-schema --header 'HeaderName: HeaderValue' 'https://foo.bar/graphql.json'

But it doesn't:

error: The following required arguments were not provided:
    <schema-location>

USAGE:
    graphql-client introspect-schema <schema-location> --header <headers>...

For more information try --help

What happens ?

Ten0 avatar May 11 '20 12:05 Ten0

We might be able to change this, but at the moment <schema-location> has to be the first argument to introspect-schema (as displayed in the USAGE section).

To take your example, this should work:

> graphql-client introspect-schema 'https://foo.bar/graphql.json' --header 'HeaderName: HeaderValue'

tomhoule avatar May 11 '20 16:05 tomhoule

Hmmm this seems to work (thanks a lot!), but that is clearly not what I understand from the USAGE section: graphql-client introspect-schema [OPTIONS] <schema-location> with [OPTIONS] as a placeholder for the

OPTIONS:
        --authorization <authorization>    Set the contents of the Authorizaiton header
        --header <headers>...              Specify custom headers. --header 'X-Name: Value'
        --output <output>                  Where to write the JSON for the introspected schema

clearly specifies the OPTIONS should be written before and not after <schema-location>. Besides, this seems to not apply for --output, which works fine when written before the <schema-location>.

(Btw, unrelated, there's a typo in the doc: Authorizaiton).

Ten0 avatar May 11 '20 17:05 Ten0