Repository: graphql-java-kickstart/graphql-java-tools (kotlin)

Issue:
Regression when invoking resolver methods that have arguments of primitive type
<!-- ⚠️ Please ensure you are reporting the bug in the correct repository! -->

## Description
Consider the following schema:

    type Query {
        testOmittedBoolean(value: Boolean): Boolean
    }

and the following resolver method:

    boolean testOmittedBoolean(boolean value) {
        return value;
    }

When executing the following query:

    query {
        testOmittedBoolean
    }

we get an exception:

    [main] WARN notprivacysafe.graphql.execution.SimpleDataFetcherExceptionHandler - Exception while fetching data (/testOmittedBoolean) : null
    java.lang.IllegalArgumentException: null
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	    at graphql.kickstart.tools.resolver.MethodFieldResolverDataFetcher.get(MethodFieldResolver.kt:261)
	    at graphql.execution.ExecutionStrategy.fetchField(ExecutionStrategy.java:277)
	    at graphql.execution.ExecutionStrategy.resolveFieldWithInfo(ExecutionStrategy.java:202)
	    at graphql.execution.AsyncExecutionStrategy.execute(AsyncExecutionStrategy.java:74)
	    at graphql.execution.Execution.executeOperation(Execution.java:167)
	    at graphql.execution.Execution.execute(Execution.java:108)
	    at graphql.GraphQL.execute(GraphQL.java:598)
	    at graphql.GraphQL.parseValidateAndExecute(GraphQL.java:529)
	    at graphql.GraphQL.executeAsync(GraphQL.java:493)
	    at graphql.GraphQL.execute(GraphQL.java:426)
	    at graphql.GraphQL.execute(GraphQL.java:398)
	at graphql.kickstart.tools.ArgumentsTest.testOmittedBooleanArgument(ArgumentsTest.java:29)

Please note, that in the schema, the argument is optional, and in the resolver it is defined as a primitive ('boolean')

### Expected behavior
In past releases, this used to work. If the argument was omitted, a default value of 'false' was passed in.
It broke recently due to the fixes related to #367
The expectation is that this query continues to work as before

### Actual behavior
The query fails with an unexpected IllegalArgumentException


### Steps to reproduce the bug

Run the following unit test:

```
public class ArgumentsTest {
    @Test
    public void testOmittedBooleanArgument() {
        GraphQLSchema schema = SchemaParser.newParser()
                .schemaString("" +
                        "type Query {" +
                        "   testOmittedBoolean(bool: Boolean): Boolean" +
                        "}")
                .resolvers(new Resolver())
                .build()
                .makeExecutableSchema();

        GraphQL gql = GraphQL.newGraphQL(schema).build();

        ExecutionResult result = gql
                .execute(ExecutionInput.newExecutionInput()
                        .query("" +
                                "query { " +
                                "  testOmittedBoolean" +
                                "}")
                        .context(new Object())
                        .root(new Object()));

        assertTrue(result.getErrors().isEmpty());
        assertEquals(false, ((Map<?, ?>) result.getData()).get("testOmittedBoolean"));
    }

    static class Resolver implements GraphQLQueryResolver {
        @SuppressWarnings("unused")
        public boolean testOmittedBoolean(boolean bool) {
            return bool;
        }
    }
}
```

Pull request description:
…use Java default value

 Fixes #461

## Checklist

- [x] Pull requests follows the [contribution guide](https://github.com/graphql-java-kickstart/graphql-java-tools/wiki/Contribution-guide)
- [x] New or modified functionality is covered by tests

## Description
Fixed MethodFieldResolver class, where a regression was introduced as part of some recent commits.
I've added a unit test that demonstrates the expected behavior

Patch:
diff --git a/src/main/kotlin/graphql/kickstart/tools/resolver/MethodFieldResolver.kt b/src/main/kotlin/graphql/kickstart/tools/resolver/MethodFieldResolver.kt
index c7a9920e..fa601737 100644
--- a/src/main/kotlin/graphql/kickstart/tools/resolver/MethodFieldResolver.kt
+++ b/src/main/kotlin/graphql/kickstart/tools/resolver/MethodFieldResolver.kt
@@ -80,7 +80,7 @@ internal class MethodFieldResolver(
                     return@add Optional.empty<Any>()
                 }
 
-                if (value != null && shouldValueBeConverted(value, definition, parameterType, environment)) {
+                if (value == null || shouldValueBeConverted(value, definition, parameterType, environment)) {
                     return@add mapper.convertValue(value, object : TypeReference<Any>() {
                         override fun getType() = parameterType
                     })


Test patch:
diff --git a/src/test/kotlin/graphql/kickstart/tools/ResolverMethodsTest.java b/src/test/kotlin/graphql/kickstart/tools/ResolverMethodsTest.java
new file mode 100644
index 00000000..dc735681
--- /dev/null
+++ b/src/test/kotlin/graphql/kickstart/tools/ResolverMethodsTest.java
@@ -0,0 +1,52 @@
+package graphql.kickstart.tools;
+
+import graphql.ExecutionInput;
+import graphql.ExecutionResult;
+import graphql.GraphQL;
+import graphql.schema.GraphQLSchema;
+import org.junit.Test;
+
+import java.util.Map;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+public class ResolverMethodsTest {
+    // Note: don't convert this code to Kotlin or Groovy, since it's quite important that the
+    //       resolver method is defined with an argument of primitive type, like 'boolean', not 'Boolean':
+    //         String testOmittedBoolean(boolean value1, Boolean value2)
+    @Test
+    public void testOmittedBooleanArgument() {
+        // In this schema, the 'value1' argument is optional, but the Java resolver defines it as 'boolean'
+        // Instead of failing with an error, we expect the argument to be set to the Java default (i.e. false for booleans)
+        GraphQLSchema schema = SchemaParser.newParser()
+                .schemaString("" +
+                        "type Query {" +
+                        "   testOmittedBoolean(value1: Boolean, value2: Boolean): String" +
+                        "}")
+                .resolvers(new Resolver())
+                .build()
+                .makeExecutableSchema();
+
+        GraphQL gql = GraphQL.newGraphQL(schema).build();
+
+        ExecutionResult result = gql
+                .execute(ExecutionInput.newExecutionInput()
+                        .query("" +
+                                "query { " +
+                                "  testOmittedBoolean" +
+                                "}")
+                        .context(new Object())
+                        .root(new Object()));
+
+        assertTrue(result.getErrors().isEmpty());
+        assertEquals("false,null", ((Map<?, ?>) result.getData()).get("testOmittedBoolean"));
+    }
+
+    static class Resolver implements GraphQLQueryResolver {
+        @SuppressWarnings("unused")
+        public String testOmittedBoolean(boolean value1, Boolean value2) {
+            return value1 + "," + value2;
+        }
+    }
+}