@@ -137,28 +137,15 @@ private void transformArgument(Annotation annotation, GraphQLDirective.Builder d
137137 methods [finalI ].setAccessible (true );
138138 Object argumentValue = methods [finalI ].invoke (annotation );
139139 Object value ;
140- if (graphQLArgument .getType () instanceof GraphQLScalarType ) {
141- // value = ((GraphQLScalarType) graphQLArgument.getType()).getCoercing().parseValue(argumentValue);
142-
143- try {
144- GraphQLScalarType argumentType = (GraphQLScalarType ) graphQLArgument .getType ();
145- if ( argumentType .equals ( Scalars .GraphQLBoolean ) )
146- {
147- value = castToBoolean ( argumentValue );
148- }
149- else
150- {
151- value = argumentType .getCoercing ().parseValue ( argumentValue );
152- }
153- builder .value ( value );
154- } catch (Exception e ) {
155- throw new GraphQLAnnotationsException (COULD_NOT_PARSE_ARGUMENT_VALUE_TO_ARGUMENT_TYPE , e );
156- }
140+ if ( graphQLArgument .getType () instanceof GraphQLScalarType )
141+ {
142+ value = parseArgumentValue ( graphQLArgument , argumentValue );
157143 }
158- else {
144+ else
145+ {
159146 value = argumentValue ;
160147 }
161- builder .value (value );
148+ builder .value ( value );
162149 } catch (Exception e ) {
163150 throw new GraphQLAnnotationsException (COULD_NOT_PARSE_ARGUMENT_VALUE_TO_ARGUMENT_TYPE , e );
164151 }
@@ -178,16 +165,7 @@ private void transformArgument(String[] argumentValues, GraphQLDirective.Builder
178165 if (graphQLArgument .getType () instanceof GraphQLScalarType ) {
179166
180167 try {
181- Object value ;
182- GraphQLScalarType argumentType = (GraphQLScalarType ) graphQLArgument .getType ();
183- if ( argumentType .equals ( Scalars .GraphQLBoolean ) )
184- {
185- value = castToBoolean ( argumentValue );
186- }
187- else
188- {
189- value = argumentType .getCoercing ().parseValue ( argumentValue );
190- }
168+ Object value = parseArgumentValue ( graphQLArgument , argumentValue );
191169 builder .value ( value );
192170 } catch (Exception e ) {
193171 throw new GraphQLAnnotationsException (COULD_NOT_PARSE_ARGUMENT_VALUE_TO_ARGUMENT_TYPE , e );
@@ -198,6 +176,19 @@ private void transformArgument(String[] argumentValues, GraphQLDirective.Builder
198176 }));
199177 }
200178
179+ private Object parseArgumentValue ( GraphQLArgument graphQLArgument , Object argumentValue )
180+ {
181+ GraphQLScalarType argumentType = (GraphQLScalarType ) graphQLArgument .getType ();
182+ if ( argumentType .equals ( Scalars .GraphQLBoolean ) )
183+ {
184+ return castToBoolean ( argumentValue );
185+ }
186+ else
187+ {
188+ return argumentType .getCoercing ().parseValue ( argumentValue );
189+ }
190+ }
191+
201192 private Boolean castToBoolean ( Object input )
202193 {
203194 if ( input instanceof Boolean )
0 commit comments