@@ -301,18 +301,28 @@ def coerce_into_values(parent_object, values, context, argument_values)
301301
302302 private
303303
304- def validate_input_type ( input_type )
304+ def validate_input_type ( input_type , wrapped : false )
305305 if input_type . is_a? ( String ) || input_type . is_a? ( GraphQL ::Schema ::LateBoundType )
306306 # Do nothing; assume this will be validated later
307+ false
307308 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
309312 elsif !input_type . kind . input?
310313 raise ArgumentError , "Invalid input type for #{ path } : #{ input_type . graphql_name } . Must be scalar, enum, or input object, not #{ input_type . kind . name } ."
311314 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
313318 end
314319 end
315320
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+
316326 def validate_deprecated_or_optional ( null :, deprecation_reason :)
317327 if deprecation_reason && !null
318328 raise ArgumentError , "Required arguments cannot be deprecated: #{ path } ."
0 commit comments