spring-graphql-common icon indicating copy to clipboard operation
spring-graphql-common copied to clipboard

InvocationTargetException masking GraphQLException in data fetcher

Open hogancr opened this issue 8 years ago • 0 comments

Because of the wrapping that takes place in spring-graphql-common, the contents of any exceptions thrown by a data fetcher (specifically mine is an @ GraphQLMutation) is blown away by the InvocationTargetException.

I followed the advice here to try and hide the stack trace info because the stack traces are outrageously large. Now all I get is

{"errors":[{"type":"DataFetchingException","message":"Exception while fetching data: com.oembedler.moon.graphql.engine.ReflectionGraphQLDataMutator$DataMutatorRuntimeException: Exception while calling data fetcher [addStationToDashboard]; nested exception is java.lang.reflect.InvocationTargetException"}]}

...despite the fact my mutation method is throwing GraphQLException with a description that makes the reason for the error clear (it's a query input validation thing that can only be done here...basically checking for the existence of some key in a map).

Not sure how to get around this, but it would be nice to have something that at least prints the message from my GraphQLExcception.

hogancr avatar Feb 07 '17 00:02 hogancr