# Schema {} query throws a TypeError

**URL:** https://discuss.dgraph.io/t/schema-query-throws-a-typeerror/14401
**Category:** Dgraph Clients
**Tags:** kind:bug, javascript-client
**Created:** [June 1, 2021, 6:59pm UTC](https://discuss.dgraph.io/t/schema-query-throws-a-typeerror/14401 "2021-06-01T18:59:21Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![dpk](https://avatars.discourse-cdn.com/v4/letter/d/ea5d25/32.png) [@dpk](https://discuss.dgraph.io/u/dpk)
#### Post date: [June 1, 2021, 6:59pm UTC](https://discuss.dgraph.io/t/schema-query-throws-a-typeerror/14401/1 "2021-06-01T18:59:21Z")

</div>

* * *

## Report a Dgraph Client Bug

### What Dgraph client (and version) are you using?

(put “x” in the box to select)

- Dgo
- PyDgraph
- Dgraph4J
- Dgraph-js (v21.03.1)
- Dgraph-js-http
- [Dgraph.NET](http://Dgraph.NET)

Version:

### What version of Dgraph are you using?

v21.03.0

### Have you tried reproducing the issue with the latest release?

Yeah.

### What is the hardware spec (RAM, OS)?

n/a

### Steps to reproduce the issue (command/config used to run Dgraph).

Run:

```auto
const txn = dgraphClient.newTxn();
const req = new dgraph.Request();
req.setQuery('schema {}');
const result = await txn.doRequest(req);

```

### Expected behaviour and actual result.

I expected to get the full schema, all types and predicates.

* * *

I get this error:

```auto
TypeError: Cannot read property 'toObject' of undefined
    at Object.stringifyMessage (/Users/dpk/Documents/git/api/node_modules/dgraph-js/lib/util.js:62:31)
    at Txn.<anonymous> (/Users/dpk/Documents/git/api/node_modules/dgraph-js/lib/txn.js:152:94)
    at step (/Users/dpk/Documents/git/api/node_modules/dgraph-js/lib/txn.js:44:23)
    at Object.next (/Users/dpk/Documents/git/api/node_modules/dgraph-js/lib/txn.js:25:53)
    at /Users/dpk/Documents/git/api/node_modules/dgraph-js/lib/txn.js:19:71
    at new Promise (<anonymous>)
    at __awaiter (/Users/dpk/Documents/git/api/node_modules/dgraph-js/lib/txn.js:15:12)
    at Txn.doRequest (/Users/dpk/Documents/git/api/node_modules/dgraph-js/lib/txn.js:143:16)

```

`req.setQuery('schema(type: Foo) {}')` works, successfully returning all the fields in type Foo.
