Custom lambda resolvers in Go

I was wondering if it would be possible to write custom lambda resolvers in Go instead of Javascript/Typescript?

Would this not be more performant since Dgraph is written in Go?

Check out GitHub - Schartey/dgraph-lambda-go. I haven’t tried it myself, but looks promising.

1 Like

Oh nice! Wasn’t aware of that! Guess it’ll take a bit until this is production ready and then I guess it’ll take a bit longer to get it on the Cloud. :stuck_out_tongue_winking_eye:

It’s just ashamed that we bob around with JS instead of working more tied to the core source - at least for stuff like custom resolvers.

Do you know if there is a similar project in Rust? :stuck_out_tongue:

Sure, but IMO Lambdas should not be deployed as CPU-bound, complex functions. JS/TS is probably just fine for their intended purpose.

Well, I agree but from my experience (and running into such scenarios various times), we quite often have use cases which require large datasets which again might be subject to string manipulations, calculations, etc. We all know that JSON in combination with JS/TS is like riding a bike with no wheels…

Would a Go/Rust environment for lambdas on the cloud not speed things up significantly?

Definitely, if a lambda was doing something incredibly CPU intensive. But the vast majority of lambdas are either simple transformations of data, and/or are network-bound to other services.

I’m not saying that support for alternative languages for lambdas is a bad idea, but probably not at the top of the list.

1 Like

Hi, I am using golang based lambda server - since before I heard about Schartey’s solution (would use it then probably).
A lambda server is basically a simple HTTP server, so can be written in any language really. You just need to understand the JSON objects structure (you probably want to talk back to your dgraph database, so existing DQL/GQL client libraries would help).

@Poolshark @miko I’m interested in understanding your use case better. I’d like to set a lambda re-design in the roadmap. I also think we have a key performance differentiator with Dgraph using Go and I would push to have Go option for Lambda. In the Cloud, I’d like to evaluate serverless options to help us manage the cost of the solution. Please DM me if you can describe your use cases in more details. We can certainly improve the user experience by visualizing which functions have hooks, custom resolvers ,auth etc. ; and by providing a debugging capability. Lambda is definitely an area that we want to strengthen. I’ll put the Lambda topic on the next steering committee agenda.

1 Like

AWS Lambdas can be written in GoLang. I think it would be cool to have the ability to write the lambdas in GO or TypeScript on the cloud, and the ability to use the Dgraph CLI to upload your own Lambdas in whatever language (at least node, go, python, or ruby like vercel).

Of course we would need to probably separate the lambdas to prevent the maximum file size problems… maybe by triggers / node etc.