Skip to content

Commit 1b2a9a6

Browse files
committed
Fix context passed to GraphQL::Schema.federation_sdl
1 parent 47c09b4 commit 1b2a9a6

File tree

7 files changed

+35
-9
lines changed

7 files changed

+35
-9
lines changed

Appraisals

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# frozen_string_literal: true
22

33
appraise 'graphql-1.9' do
4-
gem 'graphql', '1.9.8'
4+
gem 'graphql', '1.9.21'
55
end
66

77
appraise 'graphql-1.10' do
8-
gem 'graphql', '1.10.10'
8+
gem 'graphql', '1.10.14'
99
end

gemfiles/graphql_1.10.gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
source "https://rubygems.org"
44

5-
gem "graphql", "1.10.10"
5+
gem "graphql", "1.10.14"
66

77
gemspec path: "../"

gemfiles/graphql_1.10.gemfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ GEM
4242
diff-lcs (1.3)
4343
erubi (1.9.0)
4444
google-protobuf (3.12.2)
45-
graphql (1.10.10)
45+
graphql (1.10.14)
4646
i18n (1.8.3)
4747
concurrent-ruby (~> 1.0)
4848
jaro_winkler (1.5.4)
@@ -112,7 +112,7 @@ DEPENDENCIES
112112
apollo-federation!
113113
appraisal
114114
debase
115-
graphql (= 1.10.10)
115+
graphql (= 1.10.14)
116116
pry-byebug
117117
rack
118118
rake

gemfiles/graphql_1.9.gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
source "https://rubygems.org"
44

5-
gem "graphql", "1.9.8"
5+
gem "graphql", "1.9.21"
66

77
gemspec path: "../"

gemfiles/graphql_1.9.gemfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ GEM
4242
diff-lcs (1.3)
4343
erubi (1.9.0)
4444
google-protobuf (3.12.2)
45-
graphql (1.9.8)
45+
graphql (1.9.21)
4646
i18n (1.8.3)
4747
concurrent-ruby (~> 1.0)
4848
jaro_winkler (1.5.4)
@@ -112,7 +112,7 @@ DEPENDENCIES
112112
apollo-federation!
113113
appraisal
114114
debase
115-
graphql (= 1.9.8)
115+
graphql (= 1.9.21)
116116
pry-byebug
117117
rack
118118
rake

lib/apollo-federation/service_field.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def define_service_field
1919

2020
def _service
2121
schema_class = context.schema.is_a?(GraphQL::Schema) ? context.schema.class : context.schema
22-
{ sdl: schema_class.federation_sdl(context: context) }
22+
{ sdl: schema_class.federation_sdl(context: context.to_h) }
2323
end
2424
end
2525
end

spec/apollo-federation/service_field_spec.rb

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,32 @@ def execute_sdl(schema)
382382
)
383383
end
384384

385+
it 'returns SDL that honors visibility checks' do
386+
product = Class.new(base_object) do
387+
graphql_name 'Product'
388+
extend_type
389+
key fields: 'upc'
390+
field :upc, String, null: false, external: true
391+
field :secret, String, null: false, external: true do
392+
def self.visible?(context)
393+
super && context.fetch(:show_secrets, false)
394+
end
395+
end
396+
end
397+
398+
schema = Class.new(base_schema) do
399+
orphan_types product
400+
end
401+
402+
expect(execute_sdl(schema)).to match_sdl(
403+
<<~GRAPHQL,
404+
type Product @extends @key(fields: "upc") {
405+
upc: String! @external
406+
}
407+
GRAPHQL
408+
)
409+
end
410+
385411
context 'with a filter' do
386412
let(:schema) do
387413
product = Class.new(base_object) do

0 commit comments

Comments
 (0)