diff --git a/clientv2/client_test.go b/clientv2/client_test.go index da9606b..b40612e 100644 --- a/clientv2/client_test.go +++ b/clientv2/client_test.go @@ -568,6 +568,7 @@ func TestMarshalJSONValueType(t *testing.T) { if !cmp.Equal(tt.want, got) { t.Errorf("MarshalJSON() = %v, want %v", got, tt.want) } + }) } } @@ -578,6 +579,13 @@ func TestMarshalJSON(t *testing.T) { Name string `json:"name"` Number Number `json:"number"` } + + // example nested struct + type WhereInput struct { + Not *WhereInput `json:"not,omitempty"` + ID *string `json:"id,omitempty"` + } + testDate := time.Date(2021, 1, 1, 0, 0, 0, 0, time.UTC) type args struct { v any @@ -608,6 +616,23 @@ func TestMarshalJSON(t *testing.T) { }, want: []byte(`{"operationName":"query", "query":"query ($input: Number!) { input }","variables":{"input":"TWO"}}`), }, + { + name: "marshal nested", + args: args{ + v: Request{ + OperationName: "query", + Query: `query ($input: Number!) { input }`, + Variables: map[string]any{ + "where": WhereInput{ + Not: &WhereInput{ + ID: &[]string{"1"}[0], + }, + }, + }, + }, + }, + want: []byte(`{"operationName":"query", "query":"query ($input: Number!) { input }","variables":{"where":{"not":{"id":"1"}}}}`), + }, { name: "marshal a struct with custom marshaler", args: args{