@@ -131,6 +131,7 @@ private Object[] invocationArgs(DataFetchingEnvironment environment, ProcessingE
131131 return result .toArray ();
132132 }
133133
134+ @ SuppressWarnings ("ConstantConditions" )
134135 private Object buildArg (Type p , GraphQLType graphQLType , Optional <Object > arg ) {
135136 if (arg == null ) {
136137 return null ;
@@ -140,7 +141,7 @@ private Object buildArg(Type p, GraphQLType graphQLType, Optional<Object> arg) {
140141 }
141142
142143 if (p instanceof Class <?> && graphQLType instanceof GraphQLInputObjectType ) {
143- Constructor <?> constructors [] = ((Class ) p ).getConstructors ();
144+ Constructor <?>[] constructors = ((Class ) p ).getConstructors ();
144145 Constructor <?> constructor = getBuildArgConstructor (constructors );
145146 Parameter [] parameters = constructor .getParameters ();
146147
@@ -156,15 +157,23 @@ private Object buildArg(Type p, GraphQLType graphQLType, Optional<Object> arg) {
156157 return constructNewInstance (constructor , objects .toArray (new Object [objects .size ()]));
157158 }
158159 } else if (p instanceof ParameterizedType && graphQLType instanceof GraphQLList ) {
159- List <Object > list = new ArrayList <>();
160- Type subType = ((ParameterizedType ) p ).getActualTypeArguments ()[0 ];
161- GraphQLType wrappedType = ((GraphQLList ) graphQLType ).getWrappedType ();
160+ if (((ParameterizedType ) p ).getRawType () == Optional .class ) {
161+ if (arg == null ) {
162+ return null ;
163+ } else {
164+ Type subType = ((ParameterizedType ) p ).getActualTypeArguments ()[0 ];
165+ return Optional .ofNullable (buildArg (subType , graphQLType , arg ));
166+ }
167+ } else {
168+ List <Object > list = new ArrayList <>();
169+ Type subType = ((ParameterizedType ) p ).getActualTypeArguments ()[0 ];
170+ GraphQLType wrappedType = ((GraphQLList ) graphQLType ).getWrappedType ();
162171
163- for (Object item : ((List ) arg .get ())) {
164- list .add (buildArg (subType , wrappedType , Optional .ofNullable (item )));
172+ for (Object item : ((List ) arg .get ())) {
173+ list .add (buildArg (subType , wrappedType , Optional .ofNullable (item )));
174+ }
175+ return list ;
165176 }
166-
167- return list ;
168177 } else if (p instanceof ParameterizedType && ((ParameterizedType ) p ).getRawType () == Optional .class ) {
169178 Type subType = ((ParameterizedType ) p ).getActualTypeArguments ()[0 ];
170179 if (arg == null ) {
0 commit comments