Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions lib/graphql/stitching/composer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 21 additions & 1 deletion test/graphql/stitching/composer/merge_directive_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
require "test_helper"

describe 'GraphQL::Stitching::Composer, merging directives' do

def test_merges_directive_definitions
a = %|
"""a"""
Expand Down Expand Up @@ -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