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

cannot use gql query with a file that has multiple operations, even with -o OperationName switch

hrbigelow opened this issue · comments

What is the proper format for the argument for the gql query command? Is it okay to define multiple operations (both query and mutation type operations) in one file?

$ gql query -p myproject -o getProjectName --variables '{ ... }' ops.gql

Where ops.gql contains multiple operations:

// ops.gql
query getProjectName($id: Int!) {
  findProject(id: $id) {
    name
  }
}

query getProjectFull($id: Int!) {
  findProject(id: $id) {
    name
    description
  }
}

...

I get a set of error messages, one for each operation defined in the file.

  • If the file contains only a single operation, and I use -o OperationName, then it works properly.

  • If I use a file containing a single operation and omit the -o option, it interactively asks to select among the available operations (showing a radio button with a single option). Upon selecting it, the proper result is returned.

  • If I use a file with multiple operations and omit the -o option, a radio selection is shown with one button per operation. After selecting one and hitting enter, the same series of errors is returned as above.

Versions (please complete the following information):
OS X Mojave 10.14.5
graphql-cli 3.0.11

Currently we have new structure for GraphQL CLI and in the new alpha version 4.0.0-alpha.0 . We don't have query command in our new alpha version.

Could you explain your use case for using the query command?