async-graphql: Error extensions
Hi @sunli829,
Thanks a lot for implementing this! https://github.com/async-graphql/async-graphql/issues/671
Maybe I don’t know how to handle this but basically I would like to achieve this:
- I want to add code to
error.extenstions
- I also would like resolver to return
MyError
as I want to capture some types of errors (blanket usingFrom
) and do some special handling for them.
So I would like my resolver to look like this, but seems like the only way to add error.extenstions
is to return async_graphql::Error
instead? unless I create a separate method to return MyError
and change my resolver to return async_graphql::Error
?
#[Object]
impl TestMutation {
async fn test(&self, ctx: &Context<'_>) -> Result<Test, MyError> {
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 17 (2 by maintainers)
Someone mentioned about
I think it is meant to be there so that
async_graphql
can convert any thing intoasync_graphql::Error
. It is convenient but too general, leading to the need of specialization.I have a shower thought this morning (haven’t thought about it clearly), maybe
async_graphql
can consider putting it under a feature flag so that people can disable it when necessary?Yeah I understand that by design it is not possible at the moment.
I will keep this alive for a while, maybe we/others can think of some solutions.