We have two methods which handle the conversion of the response from Dgraph into the format that client expects.
- ToJSON (HTTP client)
- ToProtocolBuffer (Go and other clients)
This means that whenever any new feature (schema validation, types etc., result count, debug root) is implemented, both the functions have to be modified. What usually happens is that ToJSON is modified because it’s more commonly used and ToProtocolBuffer lags behind. This leads to inconsistencies. The idea is to write a wrapper over ToProtocolBuffer, which can convert the ProtocolBuffer response to JSON.
Add pbToJson function by pawanrawal · Pull Request #251 · dgraph-io/dgraph · GitHub is an initial attempt and produces the same output for the basic test case for ToJSON. Some modifications have to be made to make sure other tests pass. Before that just wanted to get your view on this @minions?