Schema query not working with .getJson()

Moved from GitHub dgraph-js/25

Posted by vespertilian:

I was just writing some tests, and I wanted to verify the schema state before running a function. So I constructed a schema query. I got the query to work, however res.getJson() does not extract the results from the response as I expected.

The results do seem to be present on the return object, and I worked out I could use res.toObject().schemaList to get them.

      const query = `
                schema {
        ` ;
        const res = await dgraphClient.newTxn().query(query);
        const json = res.getJson() // returns and empty object
        const object = res.toObject().schemaList; // returns schema like ratel

I am not sure what is expected here. This functionality is not documented, so I just wanted to flag it with you. I feel it would be worthwhile to document it, or if it’s a bug fix it so .getJson() works.

If it’s just a super special query maybe you can create:


gpahal commented :

Look at this issue #20

vespertilian commented :

Ok thanks.