@@ -137,28 +137,15 @@ private void transformArgument(Annotation annotation, GraphQLDirective.Builder d
137
137
methods [finalI ].setAccessible (true );
138
138
Object argumentValue = methods [finalI ].invoke (annotation );
139
139
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 );
157
143
}
158
- else {
144
+ else
145
+ {
159
146
value = argumentValue ;
160
147
}
161
- builder .value (value );
148
+ builder .value ( value );
162
149
} catch (Exception e ) {
163
150
throw new GraphQLAnnotationsException (COULD_NOT_PARSE_ARGUMENT_VALUE_TO_ARGUMENT_TYPE , e );
164
151
}
@@ -178,16 +165,7 @@ private void transformArgument(String[] argumentValues, GraphQLDirective.Builder
178
165
if (graphQLArgument .getType () instanceof GraphQLScalarType ) {
179
166
180
167
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 );
191
169
builder .value ( value );
192
170
} catch (Exception e ) {
193
171
throw new GraphQLAnnotationsException (COULD_NOT_PARSE_ARGUMENT_VALUE_TO_ARGUMENT_TYPE , e );
@@ -198,6 +176,19 @@ private void transformArgument(String[] argumentValues, GraphQLDirective.Builder
198
176
}));
199
177
}
200
178
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
+
201
192
private Boolean castToBoolean ( Object input )
202
193
{
203
194
if ( input instanceof Boolean )
0 commit comments