# Schema query not working with .getJson()

**URL:** <https://discuss.dgraph.io/t/schema-query-not-working-with-getjson/8147>\
**Category:** Dgraph Clients\
**Tags:** untagged, dgraph-js\
**Created:** [February 13, 2018, 10:08am UTC](https://discuss.dgraph.io/t/schema-query-not-working-with-getjson/8147 "2018-02-13T10:08:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![diggy](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/diggy/32/3666_2.png) [@diggy](https://discuss.dgraph.io/u/diggy)\
**Post date:** [February 13, 2018, 10:08am UTC](https://discuss.dgraph.io/t/schema-query-not-working-with-getjson/8147/1 "2018-02-13T10:08:53Z")

</div>

**Moved from GitHub [dgraph-js/25](https://github.com/dgraph-io/dgraph-js/issues/25)**

_Posted by_ [vespertilian](https://github.com/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.

```auto
      const query = `
                schema {
                    type
                    index
                    reverse
                    tokenizer
                }
        ` ;
        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:

`dgraphClient.newTxn().getSchema()`

---

<div class="post-metadata">

**Author:** ![diggy](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/diggy/32/3666_2.png) [@diggy](https://discuss.dgraph.io/u/diggy)\
**Post date:** [February 13, 2018, 10:30am UTC](https://discuss.dgraph.io/t/schema-query-not-working-with-getjson/8147/2 "2018-02-13T10:30:50Z")

</div>

[gpahal](https://github.com/gpahal) _commented_ :

Look at this issue #20

---

<div class="post-metadata">

**Author:** ![diggy](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/diggy/32/3666_2.png) [@diggy](https://discuss.dgraph.io/u/diggy)\
**Post date:** [February 13, 2018, 10:49am UTC](https://discuss.dgraph.io/t/schema-query-not-working-with-getjson/8147/3 "2018-02-13T10:49:47Z")

</div>

[vespertilian](https://github.com/vespertilian) _commented_ :

Ok thanks.

---

<div class="post-metadata">

**Author:** ![diggy](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/diggy/32/3666_2.png) [@diggy](https://discuss.dgraph.io/u/diggy)\
**Post date:** [July 11, 2020, 4:13am UTC](https://discuss.dgraph.io/t/schema-query-not-working-with-getjson/8147/4 "2020-07-11T04:13:26Z")

</div>


