@@ -13,7 +13,7 @@ import (
1313 "time"
1414
1515 "github.com/dgraph-io/dgo/v250"
16- api "github.com/dgraph-io/dgo/v250/protos/api"
16+ "github.com/dgraph-io/dgo/v250/protos/api"
1717
1818 "github.com/stretchr/testify/require"
1919)
@@ -185,6 +185,23 @@ func TestREADME(t *testing.T) {
185185 require .
Equal (
t ,
m [
"alice" ][
0 ].
Email ,
"[email protected] " )
186186 require .Equal (t , m ["alice" ][0 ].Age , 29 )
187187
188+ // JSON Response, check that we can execute the JSON received from query response
189+ // DQL with JSON Data format should be valid as per https://docs.hypermode.com/dgraph/dql/json
190+ jsonBytes , marshallErr := json .Marshal (m ["alice" ])
191+ require .NoError (t , marshallErr )
192+ mutationDQL = fmt .Sprintf (`{
193+ "set": %s
194+ }` , jsonBytes )
195+ resp , err = client .RunDQL (ctx , mutationDQL )
196+ require .NoError (t , err )
197+ require .NotEmpty (t , resp .Uids ["alice" ])
198+ resp , err = client .RunDQL (ctx , queryDQL , dgo .WithReadOnly ())
199+ require .NoError (t , err )
200+ require .NoError (t , json .Unmarshal (resp .Json , & m ))
201+ require .Equal (t , m ["alice" ][0 ].Name , "Alice" )
202+ require .
Equal (
t ,
m [
"alice" ][
0 ].
Email ,
"[email protected] " )
203+ require .Equal (t , m ["alice" ][0 ].Age , 29 )
204+
188205 // Running an upsert
189206 upsertQuery := `upsert {
190207 query {
0 commit comments