Not quite sure what it is that you after ...
Just enter a new error, it should return something like
{ "data": { "createBike": null }, "errors": [ { "message": "Not enough metal", "originalError": {} } ] }
your client side should just handle the response
if (res.errors) {res.errors[0].message}
What I am doing is passing an object with an error code and a message, at this stage the best way to do this is to execute it.
throw new Errors(JSON.stringify({ code:409, message:"Duplicate request......" }))
NOTE: you may also be interested in this library https://github.com/kadirahq/graphql-errors
you can mask all errors (include the message "Internal error") or define userError ("message to the client"), which they will not be replaced.
source share