graphql 2.4.0 → 2.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/graphql/query/null_context.rb +3 -5
- data/lib/graphql/schema/enum.rb +17 -3
- data/lib/graphql/schema/enum_value.rb +1 -1
- data/lib/graphql/schema/visibility/migration.rb +2 -1
- data/lib/graphql/schema/visibility/profile.rb +8 -4
- data/lib/graphql/schema/warden.rb +13 -9
- data/lib/graphql/testing/helpers.rb +1 -1
- data/lib/graphql/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 12a25d94ae9348527390bad889be7c918390c0a1b133735612ac5a80ca0c6633
|
4
|
+
data.tar.gz: de4bb61a31dc643d359157dff498410f70a5a7bd18d6c254463a2a5294706949
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f85c5a5e4ab0083862c990fe6cd3f0ed99d36a414721d4c3d0a7a3e5c59042cdc5611a6b74d10d0e18525d9e51a32dc6aa1a2349c789b04dae75a835f4bb322a
|
7
|
+
data.tar.gz: e0304dded75753771417672c704054a1daec13ab428ed92f97dbdcee2771f21874bfb6aedf9bd0054806ed97b4483b98376f03526b129d96628735c1933f0d35
|
@@ -18,17 +18,15 @@ module GraphQL
|
|
18
18
|
extend Forwardable
|
19
19
|
|
20
20
|
attr_reader :schema, :query, :warden, :dataloader
|
21
|
-
def_delegators GraphQL::EmptyObjects::EMPTY_HASH, :[], :fetch, :dig, :key
|
21
|
+
def_delegators GraphQL::EmptyObjects::EMPTY_HASH, :[], :fetch, :dig, :key?, :to_h
|
22
22
|
|
23
23
|
def initialize
|
24
24
|
@query = NullQuery.new
|
25
25
|
@dataloader = GraphQL::Dataloader::NullDataloader.new
|
26
26
|
@schema = NullSchema
|
27
27
|
@warden = Schema::Warden::NullWarden.new(context: self, schema: @schema)
|
28
|
-
|
29
|
-
|
30
|
-
def types
|
31
|
-
@types ||= Schema::Warden::VisibilityProfile.new(@warden)
|
28
|
+
@types = @warden.visibility_profile
|
29
|
+
freeze
|
32
30
|
end
|
33
31
|
end
|
34
32
|
end
|
data/lib/graphql/schema/enum.rb
CHANGED
@@ -86,10 +86,24 @@ module GraphQL
|
|
86
86
|
def enum_values(context = GraphQL::Query::NullContext.instance)
|
87
87
|
inherited_values = superclass.respond_to?(:enum_values) ? superclass.enum_values(context) : nil
|
88
88
|
visible_values = []
|
89
|
-
|
89
|
+
types = Warden.types_from_context(context)
|
90
90
|
own_values.each do |key, values_entry|
|
91
|
-
|
92
|
-
|
91
|
+
visible_value = nil
|
92
|
+
if values_entry.is_a?(Array)
|
93
|
+
values_entry.each do |v|
|
94
|
+
if types.visible_enum_value?(v, context)
|
95
|
+
if visible_value.nil?
|
96
|
+
visible_value = v
|
97
|
+
visible_values << v
|
98
|
+
else
|
99
|
+
raise DuplicateNamesError.new(
|
100
|
+
duplicated_name: v.path, duplicated_definition_1: visible_value.inspect, duplicated_definition_2: v.inspect
|
101
|
+
)
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
elsif types.visible_enum_value?(values_entry, context)
|
106
|
+
visible_values << values_entry
|
93
107
|
end
|
94
108
|
end
|
95
109
|
|
@@ -74,7 +74,7 @@ module GraphQL
|
|
74
74
|
end
|
75
75
|
|
76
76
|
def inspect
|
77
|
-
"#<#{self.class} #{path} @value=#{@value.inspect}#{description ? " @description=#{description.inspect}" : ""}>"
|
77
|
+
"#<#{self.class} #{path} @value=#{@value.inspect}#{description ? " @description=#{description.inspect}" : ""}#{deprecation_reason ? " @deprecation_reason=#{deprecation_reason.inspect}" : ""}>"
|
78
78
|
end
|
79
79
|
|
80
80
|
def visible?(_ctx); true; end
|
@@ -22,9 +22,9 @@ module GraphQL
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
def self.
|
26
|
-
profile = self.new(context: context, schema: schema)
|
27
|
-
profile.instance_variable_set(:@cached_visible, Hash.new { |
|
25
|
+
def self.null_profile(context:, schema:)
|
26
|
+
profile = self.new(name: "NullProfile", context: context, schema: schema)
|
27
|
+
profile.instance_variable_set(:@cached_visible, Hash.new { |k, v| k[v] = true }.compare_by_identity)
|
28
28
|
profile
|
29
29
|
end
|
30
30
|
|
@@ -123,7 +123,7 @@ module GraphQL
|
|
123
123
|
end.compare_by_identity
|
124
124
|
|
125
125
|
@cached_enum_values = Hash.new do |h, enum_t|
|
126
|
-
values = non_duplicate_items(enum_t.
|
126
|
+
values = non_duplicate_items(enum_t.enum_values(@context), @cached_visible)
|
127
127
|
if values.size == 0
|
128
128
|
raise GraphQL::Schema::Enum::MissingValuesError.new(enum_t)
|
129
129
|
end
|
@@ -327,6 +327,10 @@ module GraphQL
|
|
327
327
|
!!@all_types[name]
|
328
328
|
end
|
329
329
|
|
330
|
+
def visible_enum_value?(enum_value, _ctx = nil)
|
331
|
+
@cached_visible[enum_value]
|
332
|
+
end
|
333
|
+
|
330
334
|
private
|
331
335
|
|
332
336
|
def add_if_visible(t)
|
@@ -19,6 +19,13 @@ module GraphQL
|
|
19
19
|
PassThruWarden
|
20
20
|
end
|
21
21
|
|
22
|
+
def self.types_from_context(context)
|
23
|
+
context.types || PassThruWarden
|
24
|
+
rescue NoMethodError
|
25
|
+
# this might be a hash which won't respond to #warden
|
26
|
+
PassThruWarden
|
27
|
+
end
|
28
|
+
|
22
29
|
def self.use(schema)
|
23
30
|
# no-op
|
24
31
|
end
|
@@ -80,24 +87,17 @@ module GraphQL
|
|
80
87
|
# No-op, but for compatibility:
|
81
88
|
attr_writer :skip_warning
|
82
89
|
|
83
|
-
# @api private
|
84
|
-
module NullVisibilityProfile
|
85
|
-
def self.new(context:, schema:)
|
86
|
-
NullWarden.new(context: context, schema: schema).visibility_profile
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
90
|
attr_reader :visibility_profile
|
91
91
|
|
92
92
|
def visible_field?(field_defn, _ctx = nil, owner = nil); true; end
|
93
93
|
def visible_argument?(arg_defn, _ctx = nil); true; end
|
94
94
|
def visible_type?(type_defn, _ctx = nil); true; end
|
95
|
-
def visible_enum_value?(enum_value, _ctx = nil);
|
95
|
+
def visible_enum_value?(enum_value, _ctx = nil); enum_value.visible?(Query::NullContext.instance); end
|
96
96
|
def visible_type_membership?(type_membership, _ctx = nil); true; end
|
97
97
|
def interface_type_memberships(obj_type, _ctx = nil); obj_type.interface_type_memberships; end
|
98
98
|
def get_type(type_name); @schema.get_type(type_name, Query::NullContext.instance, false); end # rubocop:disable Development/ContextIsPassedCop
|
99
99
|
def arguments(argument_owner, ctx = nil); argument_owner.all_argument_definitions; end
|
100
|
-
def enum_values(enum_defn); enum_defn.enum_values; end # rubocop:disable Development/ContextIsPassedCop
|
100
|
+
def enum_values(enum_defn); enum_defn.enum_values(Query::NullContext.instance); end # rubocop:disable Development/ContextIsPassedCop
|
101
101
|
def get_argument(parent_type, argument_name); parent_type.get_argument(argument_name); end # rubocop:disable Development/ContextIsPassedCop
|
102
102
|
def types; @schema.types; end # rubocop:disable Development/ContextIsPassedCop
|
103
103
|
def root_type_for_operation(op_name); @schema.root_type_for_operation(op_name); end
|
@@ -183,6 +183,10 @@ module GraphQL
|
|
183
183
|
def reachable_type?(type_name)
|
184
184
|
!!@warden.reachable_type?(type_name)
|
185
185
|
end
|
186
|
+
|
187
|
+
def visible_enum_value?(enum_value, ctx = nil)
|
188
|
+
@warden.visible_enum_value?(enum_value, ctx)
|
189
|
+
end
|
186
190
|
end
|
187
191
|
|
188
192
|
# @param context [GraphQL::Query::Context]
|
@@ -92,7 +92,7 @@ module GraphQL
|
|
92
92
|
end
|
93
93
|
graphql_result
|
94
94
|
else
|
95
|
-
unfiltered_type = Schema::Visibility::Profile.
|
95
|
+
unfiltered_type = Schema::Visibility::Profile.null_profile(schema: schema, context: context).type(type_name)
|
96
96
|
if unfiltered_type
|
97
97
|
raise TypeNotVisibleError.new(type_name: type_name)
|
98
98
|
else
|
data/lib/graphql/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: graphql
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.4.
|
4
|
+
version: 2.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Mosolgo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-11-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: base64
|