Skip to content

The detail message from Checked Exceptions thrown by Resolvers is ignored in ExecutionResult.getErrors() #713

Closed
@zleonov

Description

@zleonov

Description

graphql-java-tools maps fields on GraphQL objects to methods and properties on "Resolvers" and "Data Classes" thus eliminating the boilerplate code required to setup graphql-java manually. Resolver methods are invoked via reflection and are free to throw both checked and unchecked exceptions in their method signatures.

When an exception is thrown it eventually ends up as a GraphQLError object in the ExecutionResult.getErrors() list. For runtime exceptions the resulting GraphQLError object inherits their error messages. But for checked exceptions or Throwables (which the Resolver methods are technically free to throw as well) the detail message is lost and a null is returned.

This problem does not exist in graphql-java.

Expected behavior

The detail message from Checked Exceptions thrown by Resolvers should be propogated to GraphQLError.getMessage() returned from ExecutionResult.getErrors().

Actual behavior

GraphQLError objects corresponding to Checked Exceptions thrown by Resolvers return a null in their getMessage().

Steps to reproduce the bug

  1. Create a simple hello-world demo using a GraphQLQueryResolver (and write the schema accordingly)
  2. Once the demo works, change the hello() method to throw a checked exception with a message.
  3. Examine the errors in ExecutionResult.

I have a gist that clearly demonstrates the bug: https://gist.github.com/zleonov/32f45aefdce49d4666877f4d276d5c2a

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions