graphql 2.3.14 → 2.3.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/generators/graphql/orm_mutations_base.rb +1 -1
- data/lib/generators/graphql/templates/base_resolver.erb +2 -0
- data/lib/generators/graphql/type_generator.rb +1 -1
- data/lib/graphql/analysis.rb +1 -1
- data/lib/graphql/execution/interpreter/resolve.rb +10 -6
- data/lib/graphql/language/comment.rb +18 -0
- data/lib/graphql/language/document_from_schema_definition.rb +38 -4
- data/lib/graphql/language/lexer.rb +15 -12
- data/lib/graphql/language/nodes.rb +22 -14
- data/lib/graphql/language/parser.rb +5 -0
- data/lib/graphql/language/printer.rb +23 -7
- data/lib/graphql/language.rb +6 -5
- data/lib/graphql/query.rb +1 -1
- data/lib/graphql/rubocop/graphql/field_type_in_block.rb +9 -1
- data/lib/graphql/schema/argument.rb +13 -1
- data/lib/graphql/schema/enum.rb +1 -0
- data/lib/graphql/schema/enum_value.rb +9 -1
- data/lib/graphql/schema/field.rb +23 -3
- data/lib/graphql/schema/interface.rb +1 -0
- data/lib/graphql/schema/member/base_dsl_methods.rb +15 -0
- data/lib/graphql/schema/member/has_arguments.rb +2 -2
- data/lib/graphql/schema/member/has_fields.rb +2 -2
- data/lib/graphql/schema/resolver.rb +3 -4
- data/lib/graphql/schema/visibility/migration.rb +188 -0
- data/lib/graphql/schema/visibility/subset.rb +509 -0
- data/lib/graphql/schema/visibility.rb +30 -0
- data/lib/graphql/schema.rb +46 -41
- data/lib/graphql/static_validation/rules/directives_are_in_valid_locations.rb +2 -0
- data/lib/graphql/testing/helpers.rb +2 -1
- data/lib/graphql/tracing/notifications_trace.rb +2 -2
- data/lib/graphql/version.rb +1 -1
- metadata +10 -8
- data/lib/graphql/schema/subset.rb +0 -509
- data/lib/graphql/schema/types_migration.rb +0 -187
data/lib/graphql/schema.rb
CHANGED
@@ -45,8 +45,7 @@ require "graphql/schema/mutation"
|
|
45
45
|
require "graphql/schema/has_single_input_argument"
|
46
46
|
require "graphql/schema/relay_classic_mutation"
|
47
47
|
require "graphql/schema/subscription"
|
48
|
-
require "graphql/schema/
|
49
|
-
require "graphql/schema/types_migration"
|
48
|
+
require "graphql/schema/visibility"
|
50
49
|
|
51
50
|
module GraphQL
|
52
51
|
# A GraphQL schema which may be queried with {GraphQL::Query}.
|
@@ -205,24 +204,19 @@ module GraphQL
|
|
205
204
|
@own_trace_modes ||= {}
|
206
205
|
end
|
207
206
|
|
208
|
-
module DefaultTraceClass
|
209
|
-
end
|
210
|
-
|
211
|
-
private_constant :DefaultTraceClass
|
212
|
-
|
213
207
|
def build_trace_mode(mode)
|
214
208
|
case mode
|
215
209
|
when :default
|
216
210
|
# Use the superclass's default mode if it has one, or else start an inheritance chain at the built-in base class.
|
217
|
-
base_class = (superclass.respond_to?(:trace_class_for) && superclass.trace_class_for(mode)) || GraphQL::Tracing::Trace
|
218
|
-
Class.new(base_class) do
|
211
|
+
base_class = (superclass.respond_to?(:trace_class_for) && superclass.trace_class_for(mode, build: true)) || GraphQL::Tracing::Trace
|
212
|
+
const_set(:DefaultTrace, Class.new(base_class) do
|
219
213
|
include DefaultTraceClass
|
220
|
-
end
|
214
|
+
end)
|
221
215
|
when :default_backtrace
|
222
216
|
schema_base_class = trace_class_for(:default, build: true)
|
223
|
-
Class.new(schema_base_class) do
|
217
|
+
const_set(:DefaultTraceBacktrace, Class.new(schema_base_class) do
|
224
218
|
include(GraphQL::Backtrace::Trace)
|
225
|
-
end
|
219
|
+
end)
|
226
220
|
else
|
227
221
|
# First, see if the superclass has a custom-defined class for this.
|
228
222
|
# Then, if it doesn't, use this class's default trace
|
@@ -339,8 +333,8 @@ module GraphQL
|
|
339
333
|
# @return [Hash<String => Class>] A dictionary of type classes by their GraphQL name
|
340
334
|
# @see get_type Which is more efficient for finding _one type_ by name, because it doesn't merge hashes.
|
341
335
|
def types(context = GraphQL::Query::NullContext.instance)
|
342
|
-
if
|
343
|
-
return Subset.from_context(context, self).all_types_h
|
336
|
+
if use_schema_visibility?
|
337
|
+
return Visibility::Subset.from_context(context, self).all_types_h
|
344
338
|
end
|
345
339
|
all_types = non_introspection_types.merge(introspection_system.types)
|
346
340
|
visible_types = {}
|
@@ -369,15 +363,15 @@ module GraphQL
|
|
369
363
|
# @param type_name [String]
|
370
364
|
# @return [Module, nil] A type, or nil if there's no type called `type_name`
|
371
365
|
def get_type(type_name, context = GraphQL::Query::NullContext.instance)
|
372
|
-
if
|
373
|
-
return Subset.from_context(context, self).type(type_name)
|
366
|
+
if use_schema_visibility?
|
367
|
+
return Visibility::Subset.from_context(context, self).type(type_name)
|
374
368
|
end
|
375
369
|
local_entry = own_types[type_name]
|
376
370
|
type_defn = case local_entry
|
377
371
|
when nil
|
378
372
|
nil
|
379
373
|
when Array
|
380
|
-
if context.respond_to?(:types) && context.types.is_a?(GraphQL::Schema::Subset)
|
374
|
+
if context.respond_to?(:types) && context.types.is_a?(GraphQL::Schema::Visibility::Subset)
|
381
375
|
local_entry
|
382
376
|
else
|
383
377
|
visible_t = nil
|
@@ -435,7 +429,7 @@ module GraphQL
|
|
435
429
|
if @query_object
|
436
430
|
dup_defn = new_query_object || yield
|
437
431
|
raise GraphQL::Error, "Second definition of `query(...)` (#{dup_defn.inspect}) is invalid, already configured with #{@query_object.inspect}"
|
438
|
-
elsif
|
432
|
+
elsif use_schema_visibility?
|
439
433
|
@query_object = block_given? ? lazy_load_block : new_query_object
|
440
434
|
else
|
441
435
|
@query_object = new_query_object || lazy_load_block.call
|
@@ -454,7 +448,7 @@ module GraphQL
|
|
454
448
|
if @mutation_object
|
455
449
|
dup_defn = new_mutation_object || yield
|
456
450
|
raise GraphQL::Error, "Second definition of `mutation(...)` (#{dup_defn.inspect}) is invalid, already configured with #{@mutation_object.inspect}"
|
457
|
-
elsif
|
451
|
+
elsif use_schema_visibility?
|
458
452
|
@mutation_object = block_given? ? lazy_load_block : new_mutation_object
|
459
453
|
else
|
460
454
|
@mutation_object = new_mutation_object || lazy_load_block.call
|
@@ -473,7 +467,7 @@ module GraphQL
|
|
473
467
|
if @subscription_object
|
474
468
|
dup_defn = new_subscription_object || yield
|
475
469
|
raise GraphQL::Error, "Second definition of `subscription(...)` (#{dup_defn.inspect}) is invalid, already configured with #{@subscription_object.inspect}"
|
476
|
-
elsif
|
470
|
+
elsif use_schema_visibility?
|
477
471
|
@subscription_object = block_given? ? lazy_load_block : new_subscription_object
|
478
472
|
add_subscription_extension_if_necessary
|
479
473
|
else
|
@@ -507,7 +501,7 @@ module GraphQL
|
|
507
501
|
end
|
508
502
|
|
509
503
|
def root_types
|
510
|
-
if
|
504
|
+
if use_schema_visibility?
|
511
505
|
[query, mutation, subscription].compact
|
512
506
|
else
|
513
507
|
@root_types
|
@@ -532,17 +526,17 @@ module GraphQL
|
|
532
526
|
elsif superclass.respond_to?(:subset_class)
|
533
527
|
superclass.subset_class
|
534
528
|
else
|
535
|
-
GraphQL::Schema::Subset
|
529
|
+
GraphQL::Schema::Visibility::Subset
|
536
530
|
end
|
537
531
|
end
|
538
532
|
|
539
|
-
attr_writer :subset_class, :
|
533
|
+
attr_writer :subset_class, :use_schema_visibility, :visibility
|
540
534
|
|
541
|
-
def
|
542
|
-
if defined?(@
|
543
|
-
@
|
544
|
-
elsif superclass.respond_to?(:
|
545
|
-
superclass.
|
535
|
+
def use_schema_visibility?
|
536
|
+
if defined?(@use_schema_visibility)
|
537
|
+
@use_schema_visibility
|
538
|
+
elsif superclass.respond_to?(:use_schema_visibility?)
|
539
|
+
superclass.use_schema_visibility?
|
546
540
|
else
|
547
541
|
false
|
548
542
|
end
|
@@ -552,11 +546,11 @@ module GraphQL
|
|
552
546
|
# @return [Hash<String, Module>] All possible types, if no `type` is given.
|
553
547
|
# @return [Array<Module>] Possible types for `type`, if it's given.
|
554
548
|
def possible_types(type = nil, context = GraphQL::Query::NullContext.instance)
|
555
|
-
if
|
549
|
+
if use_schema_visibility?
|
556
550
|
if type
|
557
|
-
return Subset.from_context(context, self).possible_types(type)
|
551
|
+
return Visibility::Subset.from_context(context, self).possible_types(type)
|
558
552
|
else
|
559
|
-
raise "Schema.possible_types is not implemented for `
|
553
|
+
raise "Schema.possible_types is not implemented for `use_schema_visibility?`"
|
560
554
|
end
|
561
555
|
end
|
562
556
|
if type
|
@@ -789,13 +783,11 @@ module GraphQL
|
|
789
783
|
|
790
784
|
attr_writer :validate_max_errors
|
791
785
|
|
792
|
-
def validate_max_errors(new_validate_max_errors =
|
793
|
-
if new_validate_max_errors
|
794
|
-
@validate_max_errors
|
795
|
-
elsif defined?(@validate_max_errors)
|
796
|
-
@validate_max_errors
|
786
|
+
def validate_max_errors(new_validate_max_errors = NOT_CONFIGURED)
|
787
|
+
if NOT_CONFIGURED.equal?(new_validate_max_errors)
|
788
|
+
defined?(@validate_max_errors) ? @validate_max_errors : find_inherited_value(:validate_max_errors)
|
797
789
|
else
|
798
|
-
|
790
|
+
@validate_max_errors = new_validate_max_errors
|
799
791
|
end
|
800
792
|
end
|
801
793
|
|
@@ -934,7 +926,7 @@ module GraphQL
|
|
934
926
|
To add other types to your schema, you might want `extra_types`: https://graphql-ruby.org/schema/definition.html#extra-types
|
935
927
|
ERR
|
936
928
|
end
|
937
|
-
add_type_and_traverse(new_orphan_types, root: false) unless
|
929
|
+
add_type_and_traverse(new_orphan_types, root: false) unless use_schema_visibility?
|
938
930
|
own_orphan_types.concat(new_orphan_types.flatten)
|
939
931
|
end
|
940
932
|
|
@@ -1193,7 +1185,7 @@ module GraphQL
|
|
1193
1185
|
# @param new_directive [Class]
|
1194
1186
|
# @return void
|
1195
1187
|
def directive(new_directive)
|
1196
|
-
if
|
1188
|
+
if use_schema_visibility?
|
1197
1189
|
own_directives[new_directive.graphql_name] = new_directive
|
1198
1190
|
else
|
1199
1191
|
add_type_and_traverse(new_directive, root: false)
|
@@ -1463,8 +1455,17 @@ module GraphQL
|
|
1463
1455
|
private
|
1464
1456
|
|
1465
1457
|
def add_trace_options_for(mode, new_options)
|
1466
|
-
|
1467
|
-
|
1458
|
+
if mode == :default
|
1459
|
+
own_trace_modes.each do |mode_name, t_class|
|
1460
|
+
if t_class <= DefaultTraceClass
|
1461
|
+
t_opts = trace_options_for(mode_name)
|
1462
|
+
t_opts.merge!(new_options)
|
1463
|
+
end
|
1464
|
+
end
|
1465
|
+
else
|
1466
|
+
t_opts = trace_options_for(mode)
|
1467
|
+
t_opts.merge!(new_options)
|
1468
|
+
end
|
1468
1469
|
nil
|
1469
1470
|
end
|
1470
1471
|
|
@@ -1608,5 +1609,9 @@ module GraphQL
|
|
1608
1609
|
|
1609
1610
|
# Install these here so that subclasses will also install it.
|
1610
1611
|
self.connections = GraphQL::Pagination::Connections.new(schema: self)
|
1612
|
+
|
1613
|
+
# @api private
|
1614
|
+
module DefaultTraceClass
|
1615
|
+
end
|
1611
1616
|
end
|
1612
1617
|
end
|
@@ -19,6 +19,7 @@ module GraphQL
|
|
19
19
|
GraphQL::Schema::Directive::FRAGMENT_DEFINITION => "fragment definitions",
|
20
20
|
GraphQL::Schema::Directive::FRAGMENT_SPREAD => "fragment spreads",
|
21
21
|
GraphQL::Schema::Directive::INLINE_FRAGMENT => "inline fragments",
|
22
|
+
GraphQL::Schema::Directive::VARIABLE_DEFINITION => "variable definitions",
|
22
23
|
}
|
23
24
|
|
24
25
|
SIMPLE_LOCATIONS = {
|
@@ -26,6 +27,7 @@ module GraphQL
|
|
26
27
|
Nodes::InlineFragment => GraphQL::Schema::Directive::INLINE_FRAGMENT,
|
27
28
|
Nodes::FragmentSpread => GraphQL::Schema::Directive::FRAGMENT_SPREAD,
|
28
29
|
Nodes::FragmentDefinition => GraphQL::Schema::Directive::FRAGMENT_DEFINITION,
|
30
|
+
Nodes::VariableDefinition => GraphQL::Schema::Directive::VARIABLE_DEFINITION,
|
29
31
|
}
|
30
32
|
|
31
33
|
SIMPLE_LOCATION_NODES = SIMPLE_LOCATIONS.keys
|
@@ -55,6 +55,7 @@ module GraphQL
|
|
55
55
|
visible_field = dummy_query.types.field(object_type, field_name) # rubocop:disable Development/ContextIsPassedCop
|
56
56
|
if visible_field
|
57
57
|
dummy_query.context.dataloader.run_isolated {
|
58
|
+
query_context[:current_field] = visible_field
|
58
59
|
field_args = visible_field.coerce_arguments(graphql_result, arguments, query_context)
|
59
60
|
field_args = schema.sync_lazy(field_args)
|
60
61
|
if visible_field.extras.any?
|
@@ -91,7 +92,7 @@ module GraphQL
|
|
91
92
|
end
|
92
93
|
graphql_result
|
93
94
|
else
|
94
|
-
unfiltered_type = Schema::Subset.pass_thru(schema: schema, context: context).type(type_name)
|
95
|
+
unfiltered_type = Schema::Visibility::Subset.pass_thru(schema: schema, context: context).type(type_name)
|
95
96
|
if unfiltered_type
|
96
97
|
raise TypeNotVisibleError.new(type_name: type_name)
|
97
98
|
else
|
@@ -33,8 +33,8 @@ module GraphQL
|
|
33
33
|
"resolve_type_lazy" => "resolve_type.graphql",
|
34
34
|
}.each do |trace_method, platform_key|
|
35
35
|
module_eval <<-RUBY, __FILE__, __LINE__
|
36
|
-
def #{trace_method}(**metadata, &
|
37
|
-
@notifications_engine.instrument("#{platform_key}", metadata, &
|
36
|
+
def #{trace_method}(**metadata, &block)
|
37
|
+
@notifications_engine.instrument("#{platform_key}", metadata) { super(**metadata, &block) }
|
38
38
|
end
|
39
39
|
RUBY
|
40
40
|
end
|
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.3.
|
4
|
+
version: 2.3.16
|
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-09-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: base64
|
@@ -168,16 +168,16 @@ dependencies:
|
|
168
168
|
name: rubocop
|
169
169
|
requirement: !ruby/object:Gem::Requirement
|
170
170
|
requirements:
|
171
|
-
- -
|
171
|
+
- - ">="
|
172
172
|
- !ruby/object:Gem::Version
|
173
|
-
version: '
|
173
|
+
version: '0'
|
174
174
|
type: :development
|
175
175
|
prerelease: false
|
176
176
|
version_requirements: !ruby/object:Gem::Requirement
|
177
177
|
requirements:
|
178
|
-
- -
|
178
|
+
- - ">="
|
179
179
|
- !ruby/object:Gem::Version
|
180
|
-
version: '
|
180
|
+
version: '0'
|
181
181
|
- !ruby/object:Gem::Dependency
|
182
182
|
name: jekyll
|
183
183
|
requirement: !ruby/object:Gem::Requirement
|
@@ -382,6 +382,7 @@ files:
|
|
382
382
|
- lib/graphql/language.rb
|
383
383
|
- lib/graphql/language/block_string.rb
|
384
384
|
- lib/graphql/language/cache.rb
|
385
|
+
- lib/graphql/language/comment.rb
|
385
386
|
- lib/graphql/language/definition_slice.rb
|
386
387
|
- lib/graphql/language/document_from_schema_definition.rb
|
387
388
|
- lib/graphql/language/generation.rb
|
@@ -485,11 +486,9 @@ files:
|
|
485
486
|
- lib/graphql/schema/resolver/has_payload_type.rb
|
486
487
|
- lib/graphql/schema/scalar.rb
|
487
488
|
- lib/graphql/schema/subscription.rb
|
488
|
-
- lib/graphql/schema/subset.rb
|
489
489
|
- lib/graphql/schema/timeout.rb
|
490
490
|
- lib/graphql/schema/type_expression.rb
|
491
491
|
- lib/graphql/schema/type_membership.rb
|
492
|
-
- lib/graphql/schema/types_migration.rb
|
493
492
|
- lib/graphql/schema/union.rb
|
494
493
|
- lib/graphql/schema/unique_within_type.rb
|
495
494
|
- lib/graphql/schema/validator.rb
|
@@ -502,6 +501,9 @@ files:
|
|
502
501
|
- lib/graphql/schema/validator/length_validator.rb
|
503
502
|
- lib/graphql/schema/validator/numericality_validator.rb
|
504
503
|
- lib/graphql/schema/validator/required_validator.rb
|
504
|
+
- lib/graphql/schema/visibility.rb
|
505
|
+
- lib/graphql/schema/visibility/migration.rb
|
506
|
+
- lib/graphql/schema/visibility/subset.rb
|
505
507
|
- lib/graphql/schema/warden.rb
|
506
508
|
- lib/graphql/schema/wrapper.rb
|
507
509
|
- lib/graphql/static_validation.rb
|