# Lambda return errors

**URL:** <https://discuss.dgraph.io/t/lambda-return-errors/13994>\
**Category:** GraphQL\
**Tags:** kind:enhancement, status:accepted, ticket:created, lambda\
**Created:** [May 3, 2021, 7:03pm UTC](https://discuss.dgraph.io/t/lambda-return-errors/13994 "2021-05-03T19:03:18Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anibal\_Aguirre](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/anibal_aguirre/32/8002_2.png) [@Anibal\_Aguirre](https://discuss.dgraph.io/u/Anibal_Aguirre)\
**Post date:** [May 3, 2021, 7:03pm UTC](https://discuss.dgraph.io/t/lambda-return-errors/13994/1 "2021-05-03T19:03:18Z")

</div>

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 .

```auto
 const errors = [
        {
            "message": "Custom error return from lambda mutation",
            "locations": [
                {
                    "line": 5,
                    "column": 4
                }
            ]
        }
    ];

```

```auto
{
  "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

---

<div class="post-metadata">

**Author:** ![JatinDevDG](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/jatindevdg/32/3417_2.png) [@JatinDevDG](https://discuss.dgraph.io/u/JatinDevDG)\
**Post date:** [May 4, 2021, 12:37am UTC](https://discuss.dgraph.io/t/lambda-return-errors/13994/2 "2021-05-04T00:37:40Z")

</div>

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.

> **[The @custom Directive - GraphQL](https://dgraph.io/docs/graphql/custom/directive/)**
>
> The @custom directive is used to define custom queries, mutations, and fields. The result types can be local or remote.

There is similar request previously

> [@How to return error with Lambda resolver](http://discuss.hypermode.com/t/how-to-return-error-with-lambda-resolver/12100):
>
> I am writing a lambda query resolver function to run a few GraphQL queries and order the results and then return a list. However, in some cases, I want to return a custom error from the resolver function. How can I do that?

---

<div class="post-metadata">

**Author:** ![JatinDevDG](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/jatindevdg/32/3417_2.png) [@JatinDevDG](https://discuss.dgraph.io/u/JatinDevDG)\
**Post date:** [May 4, 2021, 7:13am UTC](https://discuss.dgraph.io/t/lambda-return-errors/13994/3 "2021-05-04T07:13:59Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Anibal\_Aguirre](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/anibal_aguirre/32/8002_2.png) [@Anibal\_Aguirre](https://discuss.dgraph.io/u/Anibal_Aguirre)\
**Post date:** [May 4, 2021, 3:11pm UTC](https://discuss.dgraph.io/t/lambda-return-errors/13994/5 "2021-05-04T15:11:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Poolshark](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/poolshark/32/10074_2.png) [@Poolshark](https://discuss.dgraph.io/u/Poolshark)\
**Post date:** [November 8, 2022, 10:12am UTC](https://discuss.dgraph.io/t/lambda-return-errors/13994/6 "2022-11-08T10:12:07Z")

</div>

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