google / rejoiner

Generates a unified GraphQL schema from gRPC microservices and other Protobuf sources
https://google.github.io/rejoiner/
Apache License 2.0
3.67k stars 139 forks source link

Handle InvocationException correctly #49

Closed gurel closed 6 years ago

gurel commented 6 years ago

When method.invoke throws an InvocationTargetException the original exception is hidden in the cause of this exception. The SchemaModule then wraps that with another RuntimeException.

Because of these the correct error never reached the GraphQL Execution.

When gRPC service throws:

throw Status.UNIMPLEMENTED
                .withDescription("message from service")
                .asRuntimeException();

The messages below gets rendered on the error.

Before:

Exception while fetching data (/greetingWithException) : java.lang.reflect.InvocationTargetException

After:

Exception while fetching data (/greetingWithException) : UNIMPLEMENTED: message from service

I also added a test case to check whether GraphQLError is also handled correctly.

coveralls commented 6 years ago

Pull Request Test Coverage Report for Build 80


Changes Missing Coverage Covered Lines Changed/Added Lines %
rejoiner/src/main/java/com/google/api/graphql/rejoiner/SchemaModule.java 4 5 80.0%
<!-- Total: 4 5 80.0% -->
Totals Coverage Status
Change from base Build 79: 0.2%
Covered Lines: 807
Relevant Lines: 1930

💛 - Coveralls
siderakis commented 6 years ago

Nice, thanks!