@@ -13,7 +13,7 @@ import (
13
13
"time"
14
14
15
15
"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"
17
17
18
18
"github.com/stretchr/testify/require"
19
19
)
@@ -185,6 +185,23 @@ func TestREADME(t *testing.T) {
185
185
require .
Equal (
t ,
m [
"alice" ][
0 ].
Email ,
"[email protected] " )
186
186
require .Equal (t , m ["alice" ][0 ].Age , 29 )
187
187
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
+
188
205
// Running an upsert
189
206
upsertQuery := `upsert {
190
207
query {
0 commit comments