Skip to content

Commit 83dcdf0

Browse files
committed
check if argument is present before checking the wrapped type
1 parent 4858045 commit 83dcdf0

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/main/java/graphql/annotations/dataFetchers/MethodDataFetcher.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ private Object buildArg(Type p, GraphQLType graphQLType, Optional<Object> arg) {
146146
Constructor<?> constructor = getBuildArgConstructor(constructors);
147147
Parameter[] parameters = constructor.getParameters();
148148

149-
if (parameters.length == 1 && parameters[0].getType().isAssignableFrom((Class<?>) p)) {
149+
if (parameters.length == 1 && arg.isPresent() && parameters[0].getType().isAssignableFrom(arg.get().getClass())) {
150150
if (parameters[0].getType().isAssignableFrom(Optional.class)) {
151151
return constructNewInstance(constructor, arg);
152152
} else {

0 commit comments

Comments
 (0)