Moved from GitHub dgraph-js/10
Posted by pmualaba:
The dgraph-js documentation qoutes: “You will need to deserialize it before you can do anything useful with it.”
Since we are completely in JavaScript land when using dgraph-js, we as node/js developers only deal with JavaScript objects. Why would we then still need to imperatively do the serialization and de-serialization (Uint8/base64/JSON) in our JavaScript code. This imperative repetitive task is a great opportunity to be handled completely by dgraph-js. Data fetching libraries like axios do the same thing: you give it a JavaScript Object (axios does the JSON.stringify internally) and it returns a JavaScript Object (axios does the JSON.parse internally). Suggestion: implementing serialization type Uint8/base64 as a DgraphClientStub() option? so that dgraph-js accepts plain JavaScript Objects and returns plain JavaScript object and does the correct serialization/de-serialization intenally based on the chosen DgraphClientStub() serialization option (‘Uint8’ or ‘base64’ ) so we “don’t need to deserialize it before you can do anything useful with it.”