Server side validation and errors

Hi yall,

So im sending a form data as a graphql query to dgraph and was wondering if there is any way to easily do server side validation for that data? Of course i could use lambda but then i would need to make a lambda function for every query separately.

The second thought is that when dgraph tells me that the id is already in use or sends me some other error message. Is there any way to modify the message or somehow easily check what causes the error. For now i just see if the error string includes words like ID or password or something like that.

Hi @SamSamit , you can’t modify the error messages that are returned by dgraph. But as you said you can use lambda or custom resolvers to return errors from those endpoints, and they will be returned in dgraph response as described in below link.

https://dgraph.io/docs/graphql/custom/directive/

I don’t know your use case in detail but many graphql clients make use of the graphql introspection queries to check basic errors.

https://graphql.org/learn/introspection/