@@ -24,17 +24,14 @@ class Composer
2424 BASIC_VALUE_MERGER = -> ( values_by_location , _info ) { values_by_location . each_value . find { !_1 . nil? } }
2525
2626 # @api private
27- VISIBILITY_PROFILES_MERGER = -> ( values_by_location , _info ) { values_by_location . each_value . reduce ( :& ) }
28-
29- # @api private
30- # VISIBILITY_PROFILES_MERGER = begin
31- # f = Class.new(Formatter) do
32- # def merge_kwargs(values_by_location, _info)
33- # values_by_location.each_value.reduce(:&)
34- # end
35- # end
36- # f.new
37- # end
27+ VISIBILITY_PROFILES_MERGER = begin
28+ f = Class . new ( Formatter ) do
29+ def merge_kwargs ( values_by_location , _info )
30+ values_by_location . each_value . reduce ( :& )
31+ end
32+ end
33+ f . new
34+ end
3835
3936 # @api private
4037 COMPOSITION_VALIDATORS = [
@@ -63,8 +60,6 @@ def initialize(
6360 subscription_name : "Subscription" ,
6461 visibility_profiles : [ ] ,
6562 deprecation_merger : nil ,
66- default_value_merger : nil ,
67- directive_kwarg_merger : nil ,
6863 root_field_location_selector : nil ,
6964 root_entrypoints : nil ,
7065 formatter : nil
@@ -73,8 +68,6 @@ def initialize(
7368 @mutation_name = mutation_name
7469 @subscription_name = subscription_name
7570 @deprecation_merger = deprecation_merger || BASIC_VALUE_MERGER
76- @default_value_merger = default_value_merger || BASIC_VALUE_MERGER
77- @directive_kwarg_merger = directive_kwarg_merger || BASIC_VALUE_MERGER
7871 @root_field_location_selector = root_field_location_selector
7972 @root_entrypoints = root_entrypoints || { }
8073 @formatter = formatter || Formatter . new
@@ -434,12 +427,12 @@ def build_merged_arguments(type_name, members_by_location, owner, field_name: ni
434427 end
435428
436429 unless default_values_by_location . empty?
437- kwargs [ :default_value ] = @default_value_merger . call ( default_values_by_location , {
430+ kwargs [ :default_value ] = @formatter . merge_default_values ( default_values_by_location , Formatter :: Info . new (
438431 type_name : type_name ,
439432 field_name : field_name ,
440433 argument_name : argument_name ,
441434 directive_name : directive_name ,
442- } . tap ( & :compact! ) )
435+ ) )
443436 end
444437
445438 type = merge_value_types ( type_name , value_types , argument_name : argument_name , field_name : field_name )
@@ -468,7 +461,7 @@ def build_merged_directives(type_name, members_by_location, owner, field_name: n
468461 end
469462
470463 directives_by_name_location . each do |directive_name , directives_by_location |
471- kwarg_merger = @directive_kwarg_merger
464+ kwarg_formatter = @formatter
472465 directive_class = @schema_directives [ directive_name ]
473466 next unless directive_class
474467
@@ -491,19 +484,19 @@ def build_merged_directives(type_name, members_by_location, owner, field_name: n
491484
492485 if ( profiles = kwarg_values_by_name_location [ "profiles" ] )
493486 @visibility_profiles . merge ( profiles . each_value . reduce ( &:| ) )
494- kwarg_merger = VISIBILITY_PROFILES_MERGER
487+ kwarg_formatter = VISIBILITY_PROFILES_MERGER
495488 end
496489 end
497490
498491 kwargs = kwarg_values_by_name_location . each_with_object ( { } ) do |( kwarg_name , kwarg_values_by_location ) , memo |
499- memo [ kwarg_name . to_sym ] = kwarg_merger . call ( kwarg_values_by_location , {
492+ memo [ kwarg_name . to_sym ] = kwarg_formatter . merge_kwargs ( kwarg_values_by_location , Formatter :: Info . new (
500493 type_name : type_name ,
501494 field_name : field_name ,
502495 argument_name : argument_name ,
503496 enum_value : enum_value ,
504497 directive_name : directive_name ,
505498 kwarg_name : kwarg_name ,
506- } . tap ( & :compact! ) )
499+ ) )
507500 end
508501
509502 owner . directive ( directive_class , **kwargs )
0 commit comments