Skip to content

Commit cbc0e65

Browse files
authored
fix camelcase kwargs. (#185)
1 parent 652ea84 commit cbc0e65

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

lib/graphql/stitching/composer.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -468,8 +468,6 @@ def build_merged_directives(type_name, members_by_location, owner, field_name: n
468468
kwarg_values_by_name_location = directives_by_location.each_with_object({}) do |(location, directive), memo|
469469
directive.arguments.keyword_arguments.each do |key, value|
470470
key = key.to_s
471-
next unless directive_class.arguments[key]
472-
473471
memo[key] ||= {}
474472
memo[key][location] = value
475473
end

test/graphql/stitching/composer/merge_directive_test.rb

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
require "test_helper"
44

55
describe 'GraphQL::Stitching::Composer, merging directives' do
6-
76
def test_merges_directive_definitions
87
a = %|
98
"""a"""
@@ -78,4 +77,25 @@ def test_omits_stitching_directives_and_includes_supergraph_directives
7877
assert_equal ["source"], supergraph.schema.query.get_field("testA").directives.map(&:graphql_name)
7978
assert_equal ["source"], supergraph.schema.query.get_field("testB").directives.map(&:graphql_name)
8079
end
80+
81+
def test_merges_camel_case_directive_values
82+
a = %|
83+
directive @fizzbuzz(sfooBar: String!) on OBJECT
84+
type Test @fizzbuzz(sfooBar: "A") { field: String }
85+
type Query { test: Test }
86+
|
87+
88+
b = %|
89+
directive @fizzbuzz(sfooBar: String!) on OBJECT
90+
type Test @fizzbuzz(sfooBar: "B") { field: String }
91+
type Query { test: Test }
92+
|
93+
94+
supergraph = compose_definitions({ "a" => a, "b" => b }, {
95+
directive_kwarg_merger: ->(str_by_location, _info) { str_by_location.values.join("/") }
96+
})
97+
98+
directives = supergraph.schema.get_type("Test").directives
99+
assert_equal "A/B", directives.first.arguments.keyword_arguments[:sfoo_bar]
100+
end
81101
end

0 commit comments

Comments
 (0)