graphql-kotlin icon indicating copy to clipboard operation
graphql-kotlin copied to clipboard

Provide more details when schema generation fails

Open jillesvangurp opened this issue 3 years ago • 2 comments

Is your feature request related to a problem? Please describe. I've had a few cases where there was a problem generating a valid schema from my code. The issue is that these exceptions do not specify which part of the code is wrong.

Describe the solution you'd like A clear and concise description of what you want to happen.

If no schema can be generated for a particular class/function, specify both in the exception message.

Describe alternatives you've considered

Trace/debug logging might also help.

Additional context

The exception I encountered was com.expediagroup.graphql.generator.exceptions.TypeNotSupportedException. The root cause for this was that the data class I was returning was implementing an interface that defined a few fields. As soon as I removed the interface (I kept the fields) it was fine. Finding this was a painful process of stashing and applying changes almost line by line because the exception did not specify where in the code it failed.

jillesvangurp avatar Jun 07 '21 15:06 jillesvangurp

Same thing happens in at least a couple more cases:

  • a function returns Unit
  • an interface is used as a return value, but it has no implementations

The error message gives absolutely no useful information as to which fun or which interface.

rocketraman avatar Jun 25 '21 06:06 rocketraman

I also had one that was very difficult to troubleshoot. A method in one of our dataloaders was marked with Spring's @Transactional, which made Spring override MyClass with MyClass$enhancedBySpringSomethingSomething. The error message I got was that type Any isn't supported.

The way to find this was to add a break point where the exception is thrown, skip over about 80 calls to there until one of them mentioned the Any type, then check the class named under type => arguments => delegate => initializer => computeJavaType.

Hope this information is useful to anyone else running across this issue while debugging, or for improving the function itself. :-)

terminalnode avatar Jul 23 '22 13:07 terminalnode