graphql-kotlin
graphql-kotlin copied to clipboard
Provide more details when schema generation fails
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.
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.
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. :-)