@@ -301,18 +301,28 @@ def coerce_into_values(parent_object, values, context, argument_values)
301
301
302
302
private
303
303
304
- def validate_input_type ( input_type )
304
+ def validate_input_type ( input_type , wrapped : false )
305
305
if input_type . is_a? ( String ) || input_type . is_a? ( GraphQL ::Schema ::LateBoundType )
306
306
# Do nothing; assume this will be validated later
307
+ false
307
308
elsif input_type . kind . non_null? || input_type . kind . list?
308
- validate_input_type ( input_type . unwrap )
309
+ type_ready = validate_input_type ( input_type . unwrap , wrapped : true )
310
+ validate_default_value ( default_value , input_type ) if default_value? && type_ready && !wrapped
311
+ type_ready
309
312
elsif !input_type . kind . input?
310
313
raise ArgumentError , "Invalid input type for #{ path } : #{ input_type . graphql_name } . Must be scalar, enum, or input object, not #{ input_type . kind . name } ."
311
314
else
312
- # It's an input type, we're OK
315
+ # It's an input type, the type itself is OK but make sure the default conforms
316
+ validate_default_value ( default_value , input_type ) if default_value? && !wrapped
317
+ true
313
318
end
314
319
end
315
320
321
+ def validate_default_value ( default_value , input_type )
322
+ default_value = input_type . coerce_isolated_result ( default_value ) unless default_value . nil?
323
+ raise "BOOM" unless input_type . valid_isolated_input? ( default_value )
324
+ end
325
+
316
326
def validate_deprecated_or_optional ( null :, deprecation_reason :)
317
327
if deprecation_reason && !null
318
328
raise ArgumentError , "Required arguments cannot be deprecated: #{ path } ."
0 commit comments