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