graphql 2.3.7 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. checksums.yaml +4 -4
  2. data/lib/generators/graphql/install_generator.rb +46 -0
  3. data/lib/generators/graphql/orm_mutations_base.rb +1 -1
  4. data/lib/generators/graphql/templates/base_resolver.erb +2 -0
  5. data/lib/generators/graphql/type_generator.rb +1 -1
  6. data/lib/graphql/analysis/field_usage.rb +1 -1
  7. data/lib/graphql/analysis/query_complexity.rb +3 -3
  8. data/lib/graphql/analysis/visitor.rb +7 -6
  9. data/lib/graphql/analysis.rb +1 -1
  10. data/lib/graphql/current.rb +52 -0
  11. data/lib/graphql/dataloader/async_dataloader.rb +3 -2
  12. data/lib/graphql/dataloader/source.rb +6 -3
  13. data/lib/graphql/dataloader.rb +35 -11
  14. data/lib/graphql/execution/interpreter/arguments_cache.rb +5 -10
  15. data/lib/graphql/execution/interpreter/resolve.rb +10 -6
  16. data/lib/graphql/execution/interpreter/runtime.rb +29 -25
  17. data/lib/graphql/execution/interpreter.rb +2 -0
  18. data/lib/graphql/execution/lookahead.rb +10 -10
  19. data/lib/graphql/introspection/directive_type.rb +1 -1
  20. data/lib/graphql/introspection/entry_points.rb +2 -2
  21. data/lib/graphql/introspection/field_type.rb +1 -1
  22. data/lib/graphql/introspection/schema_type.rb +6 -11
  23. data/lib/graphql/introspection/type_type.rb +5 -5
  24. data/lib/graphql/invalid_null_error.rb +1 -1
  25. data/lib/graphql/language/comment.rb +18 -0
  26. data/lib/graphql/language/document_from_schema_definition.rb +55 -28
  27. data/lib/graphql/language/lexer.rb +15 -15
  28. data/lib/graphql/language/nodes.rb +24 -16
  29. data/lib/graphql/language/parser.rb +14 -1
  30. data/lib/graphql/language/printer.rb +23 -7
  31. data/lib/graphql/language/sanitized_printer.rb +1 -1
  32. data/lib/graphql/language.rb +6 -6
  33. data/lib/graphql/query/context.rb +7 -1
  34. data/lib/graphql/query/null_context.rb +2 -2
  35. data/lib/graphql/query.rb +60 -8
  36. data/lib/graphql/rubocop/graphql/field_type_in_block.rb +144 -0
  37. data/lib/graphql/rubocop/graphql/root_types_in_block.rb +38 -0
  38. data/lib/graphql/rubocop.rb +2 -0
  39. data/lib/graphql/schema/addition.rb +1 -0
  40. data/lib/graphql/schema/always_visible.rb +6 -2
  41. data/lib/graphql/schema/argument.rb +14 -1
  42. data/lib/graphql/schema/build_from_definition.rb +9 -1
  43. data/lib/graphql/schema/directive/flagged.rb +1 -1
  44. data/lib/graphql/schema/enum.rb +54 -20
  45. data/lib/graphql/schema/enum_value.rb +9 -1
  46. data/lib/graphql/schema/field/connection_extension.rb +1 -1
  47. data/lib/graphql/schema/field.rb +92 -37
  48. data/lib/graphql/schema/has_single_input_argument.rb +2 -1
  49. data/lib/graphql/schema/input_object.rb +27 -13
  50. data/lib/graphql/schema/interface.rb +21 -4
  51. data/lib/graphql/schema/introspection_system.rb +5 -16
  52. data/lib/graphql/schema/member/base_dsl_methods.rb +15 -0
  53. data/lib/graphql/schema/member/has_arguments.rb +14 -9
  54. data/lib/graphql/schema/member/has_fields.rb +8 -6
  55. data/lib/graphql/schema/member/has_unresolved_type_error.rb +5 -1
  56. data/lib/graphql/schema/printer.rb +1 -0
  57. data/lib/graphql/schema/resolver.rb +7 -9
  58. data/lib/graphql/schema/type_expression.rb +2 -2
  59. data/lib/graphql/schema/validator/all_validator.rb +62 -0
  60. data/lib/graphql/schema/validator/required_validator.rb +28 -4
  61. data/lib/graphql/schema/validator.rb +2 -0
  62. data/lib/graphql/schema/visibility/migration.rb +186 -0
  63. data/lib/graphql/schema/visibility/profile.rb +523 -0
  64. data/lib/graphql/schema/visibility.rb +75 -0
  65. data/lib/graphql/schema/warden.rb +156 -10
  66. data/lib/graphql/schema.rb +283 -85
  67. data/lib/graphql/static_validation/base_visitor.rb +6 -5
  68. data/lib/graphql/static_validation/literal_validator.rb +4 -4
  69. data/lib/graphql/static_validation/rules/argument_literals_are_compatible.rb +1 -1
  70. data/lib/graphql/static_validation/rules/arguments_are_defined.rb +3 -2
  71. data/lib/graphql/static_validation/rules/directives_are_defined.rb +3 -3
  72. data/lib/graphql/static_validation/rules/directives_are_in_valid_locations.rb +2 -0
  73. data/lib/graphql/static_validation/rules/fields_are_defined_on_type.rb +3 -2
  74. data/lib/graphql/static_validation/rules/fields_will_merge.rb +8 -7
  75. data/lib/graphql/static_validation/rules/fragment_spreads_are_possible.rb +3 -3
  76. data/lib/graphql/static_validation/rules/fragment_types_exist.rb +12 -2
  77. data/lib/graphql/static_validation/rules/fragments_are_on_composite_types.rb +1 -1
  78. data/lib/graphql/static_validation/rules/mutation_root_exists.rb +1 -1
  79. data/lib/graphql/static_validation/rules/query_root_exists.rb +1 -1
  80. data/lib/graphql/static_validation/rules/required_arguments_are_present.rb +3 -3
  81. data/lib/graphql/static_validation/rules/required_input_object_attributes_are_present.rb +3 -3
  82. data/lib/graphql/static_validation/rules/subscription_root_exists.rb +1 -1
  83. data/lib/graphql/static_validation/rules/variable_default_values_are_correctly_typed.rb +18 -27
  84. data/lib/graphql/static_validation/rules/variable_usages_are_allowed.rb +1 -1
  85. data/lib/graphql/static_validation/rules/variables_are_input_types.rb +11 -2
  86. data/lib/graphql/static_validation/validation_context.rb +17 -2
  87. data/lib/graphql/subscriptions/action_cable_subscriptions.rb +2 -1
  88. data/lib/graphql/subscriptions/broadcast_analyzer.rb +10 -4
  89. data/lib/graphql/subscriptions/event.rb +1 -1
  90. data/lib/graphql/subscriptions.rb +5 -3
  91. data/lib/graphql/testing/helpers.rb +9 -5
  92. data/lib/graphql/tracing/notifications_trace.rb +2 -2
  93. data/lib/graphql/types/relay/connection_behaviors.rb +10 -0
  94. data/lib/graphql/types/relay/edge_behaviors.rb +10 -0
  95. data/lib/graphql/types/relay/page_info_behaviors.rb +4 -0
  96. data/lib/graphql/unauthorized_enum_value_error.rb +13 -0
  97. data/lib/graphql/version.rb +1 -1
  98. data/lib/graphql.rb +3 -0
  99. metadata +29 -8
  100. data/lib/graphql/language/token.rb +0 -34
  101. data/lib/graphql/schema/invalid_type_error.rb +0 -7
@@ -18,6 +18,7 @@ module GraphQL
18
18
  self.node_type = nil
19
19
  self.edge_class = nil
20
20
  }
21
+ child_class.default_broadcastable(nil)
21
22
  add_page_info_field(child_class)
22
23
  end
23
24
 
@@ -31,12 +32,21 @@ module GraphQL
31
32
  child_class.edge_type = nil
32
33
  child_class.node_type = nil
33
34
  child_class.edge_class = nil
35
+ child_class.default_broadcastable(default_broadcastable?)
34
36
  end
35
37
 
36
38
  def default_relay?
37
39
  true
38
40
  end
39
41
 
42
+ def default_broadcastable?
43
+ @default_broadcastable
44
+ end
45
+
46
+ def default_broadcastable(new_value)
47
+ @default_broadcastable = new_value
48
+ end
49
+
40
50
  # @return [Class]
41
51
  attr_reader :node_type
42
52
 
@@ -10,6 +10,7 @@ module GraphQL
10
10
  child_class.extend(ClassMethods)
11
11
  child_class.class_eval { self.node_type = nil }
12
12
  child_class.node_nullable(true)
13
+ child_class.default_broadcastable(nil)
13
14
  end
14
15
 
15
16
  def node
@@ -24,12 +25,21 @@ module GraphQL
24
25
  super
25
26
  child_class.node_type = nil
26
27
  child_class.node_nullable = nil
28
+ child_class.default_broadcastable(default_broadcastable?)
27
29
  end
28
30
 
29
31
  def default_relay?
30
32
  true
31
33
  end
32
34
 
35
+ def default_broadcastable?
36
+ @default_broadcastable
37
+ end
38
+
39
+ def default_broadcastable(new_value)
40
+ @default_broadcastable = new_value
41
+ end
42
+
33
43
  # Get or set the Object type that this edge wraps.
34
44
  #
35
45
  # @param node_type [Class] A `Schema::Object` subclass
@@ -24,6 +24,10 @@ module GraphQL
24
24
  def default_relay?
25
25
  true
26
26
  end
27
+
28
+ def default_broadcastable?
29
+ true
30
+ end
27
31
  end
28
32
  end
29
33
  end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+ module GraphQL
3
+ class UnauthorizedEnumValueError < GraphQL::UnauthorizedError
4
+ # @return [GraphQL::Schema::EnumValue] The value whose `#authorized?` check returned false
5
+ attr_accessor :enum_value
6
+
7
+ def initialize(type:, context:, enum_value:)
8
+ @enum_value = enum_value
9
+ message ||= "#{enum_value.path} failed authorization"
10
+ super(message, object: enum_value.value, type: type, context: context)
11
+ end
12
+ end
13
+ end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module GraphQL
3
- VERSION = "2.3.7"
3
+ VERSION = "2.4.0"
4
4
  end
data/lib/graphql.rb CHANGED
@@ -4,6 +4,7 @@ require "json"
4
4
  require "set"
5
5
  require "singleton"
6
6
  require "forwardable"
7
+ require "fiber/storage"
7
8
 
8
9
  module GraphQL
9
10
  class Error < StandardError
@@ -118,6 +119,8 @@ require "graphql/parse_error"
118
119
  require "graphql/backtrace"
119
120
 
120
121
  require "graphql/unauthorized_error"
122
+ require "graphql/unauthorized_enum_value_error"
121
123
  require "graphql/unauthorized_field_error"
122
124
  require "graphql/load_application_object_failed_error"
123
125
  require "graphql/testing"
126
+ require "graphql/current"
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.7
4
+ version: 2.4.0
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-06-27 00:00:00.000000000 Z
11
+ date: 2024-10-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: base64
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: fiber-storage
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: benchmark-ips
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -154,16 +168,16 @@ dependencies:
154
168
  name: rubocop
155
169
  requirement: !ruby/object:Gem::Requirement
156
170
  requirements:
157
- - - '='
171
+ - - ">="
158
172
  - !ruby/object:Gem::Version
159
- version: '1.12'
173
+ version: '0'
160
174
  type: :development
161
175
  prerelease: false
162
176
  version_requirements: !ruby/object:Gem::Requirement
163
177
  requirements:
164
- - - '='
178
+ - - ">="
165
179
  - !ruby/object:Gem::Version
166
- version: '1.12'
180
+ version: '0'
167
181
  - !ruby/object:Gem::Dependency
168
182
  name: jekyll
169
183
  requirement: !ruby/object:Gem::Requirement
@@ -321,6 +335,7 @@ files:
321
335
  - lib/graphql/backtrace/traced_error.rb
322
336
  - lib/graphql/backtrace/tracer.rb
323
337
  - lib/graphql/coercion_error.rb
338
+ - lib/graphql/current.rb
324
339
  - lib/graphql/dataloader.rb
325
340
  - lib/graphql/dataloader/async_dataloader.rb
326
341
  - lib/graphql/dataloader/null_dataloader.rb
@@ -367,6 +382,7 @@ files:
367
382
  - lib/graphql/language.rb
368
383
  - lib/graphql/language/block_string.rb
369
384
  - lib/graphql/language/cache.rb
385
+ - lib/graphql/language/comment.rb
370
386
  - lib/graphql/language/definition_slice.rb
371
387
  - lib/graphql/language/document_from_schema_definition.rb
372
388
  - lib/graphql/language/generation.rb
@@ -376,7 +392,6 @@ files:
376
392
  - lib/graphql/language/printer.rb
377
393
  - lib/graphql/language/sanitized_printer.rb
378
394
  - lib/graphql/language/static_visitor.rb
379
- - lib/graphql/language/token.rb
380
395
  - lib/graphql/language/visitor.rb
381
396
  - lib/graphql/load_application_object_failed_error.rb
382
397
  - lib/graphql/name_validator.rb
@@ -408,6 +423,8 @@ files:
408
423
  - lib/graphql/rubocop/graphql/base_cop.rb
409
424
  - lib/graphql/rubocop/graphql/default_null_true.rb
410
425
  - lib/graphql/rubocop/graphql/default_required_true.rb
426
+ - lib/graphql/rubocop/graphql/field_type_in_block.rb
427
+ - lib/graphql/rubocop/graphql/root_types_in_block.rb
411
428
  - lib/graphql/runtime_type_error.rb
412
429
  - lib/graphql/schema.rb
413
430
  - lib/graphql/schema/addition.rb
@@ -439,7 +456,6 @@ files:
439
456
  - lib/graphql/schema/input_object.rb
440
457
  - lib/graphql/schema/interface.rb
441
458
  - lib/graphql/schema/introspection_system.rb
442
- - lib/graphql/schema/invalid_type_error.rb
443
459
  - lib/graphql/schema/late_bound_type.rb
444
460
  - lib/graphql/schema/list.rb
445
461
  - lib/graphql/schema/loader.rb
@@ -476,6 +492,7 @@ files:
476
492
  - lib/graphql/schema/union.rb
477
493
  - lib/graphql/schema/unique_within_type.rb
478
494
  - lib/graphql/schema/validator.rb
495
+ - lib/graphql/schema/validator/all_validator.rb
479
496
  - lib/graphql/schema/validator/allow_blank_validator.rb
480
497
  - lib/graphql/schema/validator/allow_null_validator.rb
481
498
  - lib/graphql/schema/validator/exclusion_validator.rb
@@ -484,6 +501,9 @@ files:
484
501
  - lib/graphql/schema/validator/length_validator.rb
485
502
  - lib/graphql/schema/validator/numericality_validator.rb
486
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/profile.rb
487
507
  - lib/graphql/schema/warden.rb
488
508
  - lib/graphql/schema/wrapper.rb
489
509
  - lib/graphql/static_validation.rb
@@ -614,6 +634,7 @@ files:
614
634
  - lib/graphql/types/relay/page_info.rb
615
635
  - lib/graphql/types/relay/page_info_behaviors.rb
616
636
  - lib/graphql/types/string.rb
637
+ - lib/graphql/unauthorized_enum_value_error.rb
617
638
  - lib/graphql/unauthorized_error.rb
618
639
  - lib/graphql/unauthorized_field_error.rb
619
640
  - lib/graphql/unresolved_type_error.rb
@@ -1,34 +0,0 @@
1
- # frozen_string_literal: true
2
- module GraphQL
3
- module Language
4
- # Emitted by the lexer and passed to the parser.
5
- # Contains type, value and position data.
6
- class Token
7
- # @return [Symbol] The kind of token this is
8
- attr_reader :name
9
- # @return [String] The text of this token
10
- attr_reader :value
11
- attr_reader :prev_token, :line, :col
12
-
13
- def initialize(name, value, line, col, prev_token)
14
- @name = name
15
- @value = -value
16
- @line = line
17
- @col = col
18
- @prev_token = prev_token
19
- end
20
-
21
- alias to_s value
22
- def to_i; @value.to_i; end
23
- def to_f; @value.to_f; end
24
-
25
- def line_and_column
26
- [@line, @col]
27
- end
28
-
29
- def inspect
30
- "(#{@name} #{@value.inspect} [#{@line}:#{@col}])"
31
- end
32
- end
33
- end
34
- end
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
- module GraphQL
3
- class Schema
4
- class InvalidTypeError < GraphQL::Error
5
- end
6
- end
7
- end