File tree Expand file tree Collapse file tree 3 files changed +19
-1
lines changed
Expand file tree Collapse file tree 3 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -74,6 +74,9 @@ on the format of the value:
7474- if the value starts with "@", the rest of the value is interpreted as a
7575 filename to read the value from. Pass "-" to read from standard input.
7676
77+ For GraphQL requests, all fields other than "query" and "operationName" are
78+ interpreted as GraphQL variables.
79+
7780Raw request body may be passed from the outside via a file specified by '--input'.
7881Pass "-" to read from standard input. In this mode, parameters specified via
7982'--field' flags are serialized into URL query parameters.
Original file line number Diff line number Diff line change @@ -87,7 +87,7 @@ func groupGraphQLVariables(params map[string]interface{}) map[string]interface{}
8787
8888 for key , val := range params {
8989 switch key {
90- case "query" :
90+ case "query" , "operationName" :
9191 topLevel [key ] = val
9292 default :
9393 variables [key ] = val
Original file line number Diff line number Diff line change @@ -55,6 +55,21 @@ func Test_groupGraphQLVariables(t *testing.T) {
5555 },
5656 },
5757 },
58+ {
59+ name : "query + operationName + variables" ,
60+ args : map [string ]interface {}{
61+ "query" : "query Q1{} query Q2{}" ,
62+ "operationName" : "Q1" ,
63+ "power" : 9001 ,
64+ },
65+ want : map [string ]interface {}{
66+ "query" : "query Q1{} query Q2{}" ,
67+ "operationName" : "Q1" ,
68+ "variables" : map [string ]interface {}{
69+ "power" : 9001 ,
70+ },
71+ },
72+ },
5873 }
5974 for _ , tt := range tests {
6075 t .Run (tt .name , func (t * testing.T ) {
You can’t perform that action at this time.
0 commit comments