Zion (v21.12) Documentation and Setting Up a Lambda Server

As the heading suggests, is the documentation updated for Zion? Because I have been looking for an updated one to implement a lambda server, but I can’t seem to find it. Also, is it still possible to implement a different language lambda server (like GitHub - Schartey/dgraph-lambda-go)? If so, how? I’ve heard/read that lambda servers are now running with the alpha node, and the setup now differs from the previous ones. Thank you very much!

Custom Lambda Servers should still work as before, but the flags for startup have changed. It now has its own flag.

dgraph alpha ... --lambda "url=http://lambda:8686/graphql-worker"

You can implement your lambda server in any language that supports web serving. The only requirement is to listen on the url you specified for POST requests.
You can have a look at the lambda implementation details by the DGraph team here. There is no further documentation about the request body, you will have to check the code for that afaik.

What you have to consider:

  • Custom lambda servers are not supported on DGraph Cloud.
  • Latency increases in comparison to running lambdas directly on alpha as requests have to be sent to your server location. But that depends on your setup.
  • You cannot currently use both alpha lambdas and custom lambdas. I’m currently working on support for this within Dgraph.

If you self host your server and want to use lambdas on alpha using JavaScript, you can use the admin api:

		"""
		Update the lambda script used by lambda resolvers.
		"""
		updateLambdaScript(input: UpdateLambdaScriptInput!) : UpdateLambdaScriptPayload

Unfortunately this is not yet documented. You can take a look at the schema here. Just search for “updateLambda” and you will find what you need.

2 Likes

Hi Schartey! Thank you so much for replying. I was having problems yesterday, and I see what I missed there: the quotation marks :joy: Btw, I’m a big fan of your dgraph-lambda-go project, and it’s what inspired me to write my own. Again, thank you very much!

Can I upload the lambda script in file via post(with binary file as request body)? Just like schema.graphql via admin/schema endpiont.

Can you please share an example of mutation? Thanks

updateLambdaScript no longer works for v23.0.1. Updating always returns error like:

    "errors": [
        {
            "message": "Cannot query field \"updateLambdaScript\" on type \"Mutation\".",
            "locations": [
                {
                    "line": 2,
                    "column": 2
                }
            ]
        }
    ]

I raised a ticket for this issue http://discuss.dgraph.io/t/how-to-update-lambda-functions-for-dgraph-v23-0-1/18868?u=ann_zhang