Lambda return errors

Hi,

We are testing lambdas mutation resolvers to add some business logic.

We would need to return some validation errors from the lambdas mutation resolver.

I’ve been playing adding error object to the errors JSON array, but mutation resolver is expecting the registered type .

 const errors = [
        {
            "message": "Custom error return from lambda mutation",
            "locations": [
                {
                    "line": 5,
                    "column": 4
                }
            ]
        }
    ];
{
  "errors": [
    {
      "message": "Non-nullable field 'id' (type ID!) was not present in result from Dgraph.  GraphQL error propagation triggered.",
      "locations": [
        {
          "line": 3,
          "column": 5
        }
      ],
      "path": [
        "newOrderHeader",
        "id"
      ]
    }
  ],
  "data": null,
  "extensions": {
    "tracing": {
      "version": 1,
      "startTime": "2021-05-03T18:59:15.100679846Z",
      "endTime": "2021-05-03T18:59:15.157225308Z",
      "duration": 56545462
    }
  }
}

What would be the way to do this ? I did not find anything on the documentation.

Thanks

Regards

Hi @Anibal_Aguirre , Welcome to Dgraph Community!!
We do have way to return errors from custom endpoint, not sure how to return that with lambdas. I am looking into it and get back to you soon.

There is similar request previously

Currently, returning errors from lamda are not supported. Accepting it as a feature request and try to add it soon. Thanks.

3 Likes

Thanks for your response. Our plan is to implement business logic using lambdas, do you have any estimation when that feature will be added ?

2 Likes

Is there any follow up on this? Would be awesome if we could have proper status codes returned from custom lambdas.