Enigmatis / graphql-java-annotations

GraphQL Annotations for Java

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bug in MethodDataFetcher:buildArg

singh-sardar opened this issue · comments

I'm using version 8.2 and writing a mutation that takes an Object as argument. After digging around for a while i found out #78 applies to my case (Documentation must be improved).

I have a class that has 2 constructors, first one with no args and a second one that take a HashMap to initialize object fields as per #78 . Even if I had the constructor that takes the HashMap as argument it wasn't being called.

After a bit of debugging i found out that the constructors order matter 'cause the code just checks the first constructor and if it's the HashMap one, call it else call the default constructor.

So, in oder to solve the bug there must be added a loop that search in all the class constructors if the HashMap one exists, if it don't it should call the default one. The code must be added in MethodDataFetcher:buildArg.

commented

Hey, you are welcome to PR the fix.
I wonder if we should depend on the order of the constructors (or in your suggestion, give the HashMap one a precedence), or maybe use some annotation to specify what constructor should be used. Let me know what you think about that.

I think the best and the more clean way is to implement a custom annotation.
I've implemented an annotation named @GraphQLConstructor in order resolve the problem and opened a pull request. Can i ask when it will be released ?

@yarinvak is it possibile to merge and release the fix as soon as possible ? I need it to go to production.

commented

Merged, released in v8.3