@@ -299,18 +299,28 @@ def coerce_into_values(parent_object, values, context, argument_values)
299299
300300 private
301301
302- def validate_input_type ( input_type )
302+ def validate_input_type ( input_type , wrapped : false )
303303 if input_type . is_a? ( String ) || input_type . is_a? ( GraphQL ::Schema ::LateBoundType )
304304 # Do nothing; assume this will be validated later
305+ false
305306 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
307310 elsif !input_type . kind . input?
308311 raise ArgumentError , "Invalid input type for #{ path } : #{ input_type . graphql_name } . Must be scalar, enum, or input object, not #{ input_type . kind . name } ."
309312 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
311316 end
312317 end
313318
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+
314324 def validate_deprecated_or_optional ( null :, deprecation_reason :)
315325 if deprecation_reason && !null
316326 raise ArgumentError , "Required arguments cannot be deprecated: #{ path } ."
0 commit comments