FunctionDataFetcher: does not handle Error
descendant Throwables
in runBlockingFunction
in conjunction with GraphQL Java graphql/execution/ExecutionStrategy.java
#1965
Labels
type: bug
Something isn't working
Library Version
Latest 7.1.1
Describe the bug
The way this library interacts with
graphql-java
, any non-blocking resolvers that lead to a result of a thrownThrowable
descendant fromError
and notException
will not be handled as expected in theerrors
field of the response, but rather result in aHTTP - 500
error (depending on specific server implementation).So like this example here:
graphql-kotlin/website/docs/schema-generator/execution/fetching-data.md
Lines 39 to 45 in 862460e
If you instead had this (
fun
instead ofsuspend fun
):You run into the problem where this will be handled as expected:
but this will not:
This is because of the
graphql-java
parent scope that does catch anyException
but notError
descendantThrowable
s:https://github.com/graphql-java/graphql-java/blob/25667a13e528a2b2c4fa372b363ffbb00184316a/src/main/java/graphql/execution/ExecutionStrategy.java#L322-L339.
In my case a nested scope throwing the
kotlin.NotImplementedError
brought this to my attention.To Reproduce
No particular schema/config needed, just have the following:
Attached is a minimal Spring Boot app you can run locally and easily observe the behavior using following query and uncommenting the various resolvers:
graphql-kotlin-error-example.zip
Expected behavior
The expected
errors
handling like this:Instead of the current behavior which is an unhandled server error like this:
The text was updated successfully, but these errors were encountered: