Hi all! I've started exploring kgraphql and really...
# kgraphql
t
Hi all! I've started exploring kgraphql and really like the approach! One bit which is unclear to me, and I can't find any mention of it in the docs, is how to return an error? When an error is thrown inside a resolver its returned as an error, but is there any other way to return an error while still maintaining control? Basically our normally errors bubble up inside an Either and so it seems a bit odd to throw in the resolver at the very end. Thanks!
Okay so afaict it looks like you cannot return an error type directly from a resovler as the library expects it to be thrown. so for now i've created a helper function to fold an Either<Failure, T> -> T or throw GraphQLError
j
Hi, you are correct. Currently KGraphQL does not have the best support for errors. But the idea is you should not return errors but rather just throw exceptions when an error occurs
t
I'd rather avoid throwing! What we've done for now, is since our code uses Either, we can let our error type propagate up to the resolver and then we throw at the very last instant (or return a value). Seems to be working well for the moment.