Skip to content

Schema query not working with .getJson() #25

@vespertilian

Description

@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 {
                    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()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions