diff --git a/cmd/query.go b/cmd/query.go index 0c9f3b80e..42f49dded 100644 --- a/cmd/query.go +++ b/cmd/query.go @@ -2,6 +2,8 @@ package cmd import ( "encoding/json" + "io/ioutil" + "os" "github.com/circleci/circleci-cli/client" "github.com/spf13/cobra" @@ -17,32 +19,10 @@ var queryCmd = &cobra.Command{ func query(cmd *cobra.Command, args []string) { client := client.NewClient(viper.GetString("host"), viper.GetString("token"), Logger) - query := ` - query IntrospectionQuery { - __schema { - queryType { name } - mutationType { name } - subscriptionType { name } - types { - ...FullType - } - directives { - name - description - } - } - } + query, err := ioutil.ReadAll(os.Stdin) + Logger.FatalOnError("Something happened", err) - fragment FullType on __Type { - kind - name - description - fields(includeDeprecated: true) { - name - } - }` - - resp, err := client.Run(query) + resp, err := client.Run(string(query)) Logger.FatalOnError("Something happend", err) b, err := json.MarshalIndent(resp, "", " ") Logger.FatalOnError("Could not parse graphql response", err) diff --git a/testquery.gql b/testquery.gql new file mode 100644 index 000000000..004df04bf --- /dev/null +++ b/testquery.gql @@ -0,0 +1,23 @@ + query IntrospectionQuery { + __schema { + queryType { name } + mutationType { name } + subscriptionType { name } + types { + ...FullType + } + directives { + name + description + } + } + } + + fragment FullType on __Type { + kind + name + description + fields(includeDeprecated: true) { + name + } + } \ No newline at end of file