From d1382456a31d7ac161bdaef44b9e884ca4940330 Mon Sep 17 00:00:00 2001 From: Greg MacWilliam Date: Thu, 5 Jun 2025 20:39:06 -0400 Subject: [PATCH] fix camelcase kwargs. --- lib/graphql/stitching/composer.rb | 2 -- .../composer/merge_directive_test.rb | 22 ++++++++++++++++++- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/lib/graphql/stitching/composer.rb b/lib/graphql/stitching/composer.rb index 00fc2989..0652d6b3 100644 --- a/lib/graphql/stitching/composer.rb +++ b/lib/graphql/stitching/composer.rb @@ -468,8 +468,6 @@ def build_merged_directives(type_name, members_by_location, owner, field_name: n kwarg_values_by_name_location = directives_by_location.each_with_object({}) do |(location, directive), memo| directive.arguments.keyword_arguments.each do |key, value| key = key.to_s - next unless directive_class.arguments[key] - memo[key] ||= {} memo[key][location] = value end diff --git a/test/graphql/stitching/composer/merge_directive_test.rb b/test/graphql/stitching/composer/merge_directive_test.rb index 50a4f14d..9a877c09 100644 --- a/test/graphql/stitching/composer/merge_directive_test.rb +++ b/test/graphql/stitching/composer/merge_directive_test.rb @@ -3,7 +3,6 @@ require "test_helper" describe 'GraphQL::Stitching::Composer, merging directives' do - def test_merges_directive_definitions a = %| """a""" @@ -78,4 +77,25 @@ def test_omits_stitching_directives_and_includes_supergraph_directives assert_equal ["source"], supergraph.schema.query.get_field("testA").directives.map(&:graphql_name) assert_equal ["source"], supergraph.schema.query.get_field("testB").directives.map(&:graphql_name) end + + def test_merges_camel_case_directive_values + a = %| + directive @fizzbuzz(sfooBar: String!) on OBJECT + type Test @fizzbuzz(sfooBar: "A") { field: String } + type Query { test: Test } + | + + b = %| + directive @fizzbuzz(sfooBar: String!) on OBJECT + type Test @fizzbuzz(sfooBar: "B") { field: String } + type Query { test: Test } + | + + supergraph = compose_definitions({ "a" => a, "b" => b }, { + directive_kwarg_merger: ->(str_by_location, _info) { str_by_location.values.join("/") } + }) + + directives = supergraph.schema.get_type("Test").directives + assert_equal "A/B", directives.first.arguments.keyword_arguments[:sfoo_bar] + end end