Golang: a small helper for manipulating gRPC responses

Hello Dgraph community,

I started working with Dgraph few days ago. And while I prefer to work with the Go client (and the gRPC interface) I found that it’s quite tedious to work with the responses so I started working on a small helper library today and thought it might be useful to some of you.

With it you can do stuff like:

import "github.com/etix/xdgraph"

[...]

xd := xdgraph.ReadResponse(resp)

// Get the UID of the "me" attribute
xd.Attribute("me").Uid()

// Get the "name" property of the "me" attribute
xd.Attribute("me").Property("name").ToString()

// Use different types
xd.Attribute("me").Attribute("follows").Property("birthdate").ToDate()

[...]

It’s available on Github if you want to give it a try :slight_smile:
Pull-requests are welcome!

3 Likes

Thanks @etix

That looks really helpful. Would you like to contribute to the Dgraph Go client by adding some of this functionality?

Hi @pawan,

It’d be great! I’ve opened an issue on Github to discuss a possible integration.

Yes, this does look useful. You could even make it a bit like Gremlin:
xd.out("me").out("follows").values("birthdate").ToDate()

Integration with Dgraph Go client would be great.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.