graphql 2.4.4 → 2.4.5

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 (63) hide show
  1. checksums.yaml +4 -4
  2. data/lib/graphql/analysis/visitor.rb +1 -1
  3. data/lib/graphql/analysis.rb +3 -3
  4. data/lib/graphql/autoload.rb +37 -0
  5. data/lib/graphql/current.rb +1 -1
  6. data/lib/graphql/dataloader/async_dataloader.rb +4 -4
  7. data/lib/graphql/dataloader/source.rb +1 -1
  8. data/lib/graphql/dataloader.rb +6 -9
  9. data/lib/graphql/execution/interpreter/resolve.rb +3 -3
  10. data/lib/graphql/execution/interpreter/runtime.rb +7 -7
  11. data/lib/graphql/execution/interpreter.rb +4 -4
  12. data/lib/graphql/language/cache.rb +13 -0
  13. data/lib/graphql/language/document_from_schema_definition.rb +8 -7
  14. data/lib/graphql/language/lexer.rb +4 -1
  15. data/lib/graphql/language/printer.rb +8 -8
  16. data/lib/graphql/pagination/connection.rb +1 -1
  17. data/lib/graphql/query/context/scoped_context.rb +1 -1
  18. data/lib/graphql/query/context.rb +6 -5
  19. data/lib/graphql/query/variable_validation_error.rb +1 -1
  20. data/lib/graphql/query.rb +12 -10
  21. data/lib/graphql/railtie.rb +7 -0
  22. data/lib/graphql/schema/addition.rb +1 -1
  23. data/lib/graphql/schema/directive/flagged.rb +1 -1
  24. data/lib/graphql/schema/directive.rb +1 -1
  25. data/lib/graphql/schema/field/scope_extension.rb +1 -1
  26. data/lib/graphql/schema/field.rb +10 -10
  27. data/lib/graphql/schema/field_extension.rb +1 -1
  28. data/lib/graphql/schema/has_single_input_argument.rb +3 -1
  29. data/lib/graphql/schema/input_object.rb +64 -27
  30. data/lib/graphql/schema/interface.rb +1 -1
  31. data/lib/graphql/schema/loader.rb +1 -1
  32. data/lib/graphql/schema/member/has_arguments.rb +12 -12
  33. data/lib/graphql/schema/member/has_directives.rb +3 -3
  34. data/lib/graphql/schema/member/has_fields.rb +18 -0
  35. data/lib/graphql/schema/member/has_interfaces.rb +4 -4
  36. data/lib/graphql/schema/member/has_validators.rb +1 -1
  37. data/lib/graphql/schema/object.rb +8 -0
  38. data/lib/graphql/schema/relay_classic_mutation.rb +0 -1
  39. data/lib/graphql/schema/resolver.rb +5 -5
  40. data/lib/graphql/schema/subscription.rb +2 -2
  41. data/lib/graphql/schema/union.rb +1 -1
  42. data/lib/graphql/schema/validator.rb +1 -1
  43. data/lib/graphql/schema/visibility/profile.rb +4 -2
  44. data/lib/graphql/schema/visibility/visit.rb +2 -2
  45. data/lib/graphql/schema/visibility.rb +33 -19
  46. data/lib/graphql/schema/warden.rb +4 -4
  47. data/lib/graphql/schema.rb +15 -9
  48. data/lib/graphql/static_validation/rules/argument_names_are_unique.rb +1 -1
  49. data/lib/graphql/static_validation/rules/fields_have_appropriate_selections.rb +1 -1
  50. data/lib/graphql/static_validation/rules/no_definitions_are_present.rb +1 -1
  51. data/lib/graphql/static_validation/rules/required_arguments_are_present.rb +1 -1
  52. data/lib/graphql/static_validation/rules/unique_directives_per_location.rb +1 -1
  53. data/lib/graphql/static_validation/rules/variable_names_are_unique.rb +1 -1
  54. data/lib/graphql/static_validation/rules/variable_usages_are_allowed.rb +1 -1
  55. data/lib/graphql/subscriptions/action_cable_subscriptions.rb +1 -1
  56. data/lib/graphql/subscriptions.rb +1 -1
  57. data/lib/graphql/testing/helpers.rb +2 -2
  58. data/lib/graphql/types/relay/connection_behaviors.rb +2 -2
  59. data/lib/graphql/types/relay/edge_behaviors.rb +1 -1
  60. data/lib/graphql/types.rb +18 -11
  61. data/lib/graphql/version.rb +1 -1
  62. data/lib/graphql.rb +80 -47
  63. metadata +3 -2
@@ -37,7 +37,7 @@ module GraphQL
37
37
  @interface_type_memberships = nil
38
38
  @directives = nil
39
39
  @types = nil
40
- @references = nil
40
+ @all_references = nil
41
41
  @loaded_all = false
42
42
  end
43
43
 
@@ -53,7 +53,7 @@ module GraphQL
53
53
 
54
54
  def all_references
55
55
  load_all
56
- @references
56
+ @all_references
57
57
  end
58
58
 
59
59
  def get_type(type_name)
@@ -146,7 +146,7 @@ module GraphQL
146
146
  attr_reader :cached_profiles
147
147
 
148
148
  def profile_for(context, visibility_profile)
149
- if @profiles.any?
149
+ if !@profiles.empty?
150
150
  if visibility_profile.nil?
151
151
  if @dynamic
152
152
  if context.is_a?(Query::NullContext)
@@ -154,7 +154,7 @@ module GraphQL
154
154
  else
155
155
  @schema.visibility_profile_class.new(context: context, schema: @schema)
156
156
  end
157
- elsif @profiles.any?
157
+ elsif !@profiles.empty?
158
158
  raise ArgumentError, "#{@schema} expects a visibility profile, but `visibility_profile:` wasn't passed. Provide a `visibility_profile:` value or add `dynamic: true` to your visibility configuration."
159
159
  end
160
160
  elsif !@profiles.include?(visibility_profile)
@@ -202,7 +202,7 @@ module GraphQL
202
202
  @interface_type_memberships = Hash.new { |h, interface_type| h[interface_type] = [] }.compare_by_identity
203
203
  @directives = []
204
204
  @types = {} # String => Module
205
- @references = Hash.new { |h, member| h[member] = [] }.compare_by_identity
205
+ @all_references = Hash.new { |h, member| h[member] = Set.new.compare_by_identity }.compare_by_identity
206
206
  @unions_for_references = Set.new
207
207
  @visit = Visibility::Visit.new(@schema) do |member|
208
208
  if member.is_a?(Module)
@@ -216,11 +216,12 @@ module GraphQL
216
216
  else
217
217
  @types[member.graphql_name] = member
218
218
  end
219
+ member.directives.each { |dir| @all_references[dir.class] << member }
219
220
  if member < GraphQL::Schema::Directive
220
221
  @directives << member
221
222
  elsif member.respond_to?(:interface_type_memberships)
222
223
  member.interface_type_memberships.each do |itm|
223
- @references[itm.abstract_type] << member
224
+ @all_references[itm.abstract_type] << member
224
225
  @interface_type_memberships[itm.abstract_type] << itm
225
226
  end
226
227
  elsif member < GraphQL::Schema::Union
@@ -228,20 +229,33 @@ module GraphQL
228
229
  end
229
230
  elsif member.is_a?(GraphQL::Schema::Argument)
230
231
  member.validate_default_value
231
- @references[member.type.unwrap] << member
232
+ @all_references[member.type.unwrap] << member
233
+ if !(dirs = member.directives).empty?
234
+ dir_owner = member.owner
235
+ if dir_owner.respond_to?(:owner)
236
+ dir_owner = dir_owner.owner
237
+ end
238
+ dirs.each { |dir| @all_references[dir.class] << dir_owner }
239
+ end
232
240
  elsif member.is_a?(GraphQL::Schema::Field)
233
- @references[member.type.unwrap] << member
241
+ @all_references[member.type.unwrap] << member
242
+ if !(dirs = member.directives).empty?
243
+ dir_owner = member.owner
244
+ dirs.each { |dir| @all_references[dir.class] << dir_owner }
245
+ end
246
+ elsif member.is_a?(GraphQL::Schema::EnumValue)
247
+ if !(dirs = member.directives).empty?
248
+ dir_owner = member.owner
249
+ dirs.each { |dir| @all_references[dir.class] << dir_owner }
250
+ end
234
251
  end
235
252
  true
236
253
  end
237
254
 
238
- @schema.root_types.each do |t|
239
- @references[t] << true
240
- end
255
+ @schema.root_types.each { |t| @all_references[t] << true }
256
+ @schema.introspection_system.types.each_value { |t| @all_references[t] << true }
257
+ @schema.directives.each_value { |dir_class| @all_references[dir_class] << true }
241
258
 
242
- @schema.introspection_system.types.each_value do |t|
243
- @references[t] << true
244
- end
245
259
  @visit.visit_each(types: []) # visit default directives
246
260
  end
247
261
 
@@ -258,20 +272,20 @@ module GraphQL
258
272
  # TODO: somehow don't iterate over all these,
259
273
  # only the ones that may have been modified
260
274
  @interface_type_memberships.each do |int_type, type_memberships|
261
- referers = @references[int_type].select { |r| r.is_a?(GraphQL::Schema::Field) }
262
- if referers.any?
275
+ referers = @all_references[int_type].select { |r| r.is_a?(GraphQL::Schema::Field) }
276
+ if !referers.empty?
263
277
  type_memberships.each do |type_membership|
264
278
  implementor_type = type_membership.object_type
265
279
  # Add new items only:
266
- @references[implementor_type] |= referers
280
+ @all_references[implementor_type] |= referers
267
281
  end
268
282
  end
269
283
  end
270
284
 
271
285
  @unions_for_references.each do |union_type|
272
- refs = @references[union_type]
286
+ refs = @all_references[union_type]
273
287
  union_type.all_possible_types.each do |object_type|
274
- @references[object_type] |= refs # Add new items
288
+ @all_references[object_type] |= refs # Add new items
275
289
  end
276
290
  end
277
291
  end
@@ -297,7 +297,7 @@ module GraphQL
297
297
  def arguments(argument_owner, ctx = nil)
298
298
  @visible_arguments ||= read_through { |o|
299
299
  args = o.arguments(@context)
300
- if args.any?
300
+ if !args.empty?
301
301
  args = args.values
302
302
  args.select! { |a| visible_argument?(a, @context) }
303
303
  args
@@ -329,7 +329,7 @@ module GraphQL
329
329
  def interfaces(obj_type)
330
330
  @visible_interfaces ||= read_through { |t|
331
331
  ints = t.interfaces(@context)
332
- if ints.any?
332
+ if !ints.empty?
333
333
  ints.select! { |i| visible_type?(i) }
334
334
  end
335
335
  ints
@@ -389,9 +389,9 @@ module GraphQL
389
389
  next true if root_type?(type_defn) || type_defn.introspection?
390
390
 
391
391
  if type_defn.kind.union?
392
- possible_types(type_defn).any? && (referenced?(type_defn) || orphan_type?(type_defn))
392
+ !possible_types(type_defn).empty? && (referenced?(type_defn) || orphan_type?(type_defn))
393
393
  elsif type_defn.kind.interface?
394
- if possible_types(type_defn).any?
394
+ if !possible_types(type_defn).empty?
395
395
  true
396
396
  else
397
397
  if @context.respond_to?(:logger) && (logger = @context.logger)
@@ -47,6 +47,8 @@ require "graphql/schema/relay_classic_mutation"
47
47
  require "graphql/schema/subscription"
48
48
  require "graphql/schema/visibility"
49
49
 
50
+ GraphQL.ensure_eager_load!
51
+
50
52
  module GraphQL
51
53
  # A GraphQL schema which may be queried with {GraphQL::Query}.
52
54
  #
@@ -233,7 +235,7 @@ module GraphQL
233
235
  add_trace_options_for(mode, default_options)
234
236
 
235
237
  Class.new(base_class) do
236
- mods.any? && include(*mods)
238
+ !mods.empty? && include(*mods)
237
239
  end
238
240
  end
239
241
  end
@@ -321,7 +323,7 @@ module GraphQL
321
323
  # @param plugin [#use] A Schema plugin
322
324
  # @return void
323
325
  def use(plugin, **kwargs)
324
- if kwargs.any?
326
+ if !kwargs.empty?
325
327
  plugin.use(self, **kwargs)
326
328
  else
327
329
  plugin.use(self)
@@ -691,7 +693,7 @@ module GraphQL
691
693
  # and generally speaking, we won't inherit any values.
692
694
  # So optimize the most common case -- don't create a duplicate Hash.
693
695
  inherited_value = find_inherited_value(:references_to, EMPTY_HASH)
694
- if inherited_value.any?
696
+ if !inherited_value.empty?
695
697
  inherited_value.merge(own_references_to)
696
698
  else
697
699
  own_references_to
@@ -977,7 +979,7 @@ module GraphQL
977
979
  # @param new_extra_types [Module] Type definitions to include in printing and introspection, even though they aren't referenced in the schema
978
980
  # @return [Array<Module>] Type definitions added to this schema
979
981
  def extra_types(*new_extra_types)
980
- if new_extra_types.any?
982
+ if !new_extra_types.empty?
981
983
  new_extra_types = new_extra_types.flatten
982
984
  @own_extra_types ||= []
983
985
  @own_extra_types.concat(new_extra_types)
@@ -1002,10 +1004,10 @@ module GraphQL
1002
1004
  # @param new_orphan_types [Array<Class<GraphQL::Schema::Object>>] Object types to register as implementations of interfaces in the schema.
1003
1005
  # @return [Array<Class<GraphQL::Schema::Object>>] All previously-registered orphan types for this schema
1004
1006
  def orphan_types(*new_orphan_types)
1005
- if new_orphan_types.any?
1007
+ if !new_orphan_types.empty?
1006
1008
  new_orphan_types = new_orphan_types.flatten
1007
1009
  non_object_types = new_orphan_types.reject { |ot| ot.is_a?(Class) && ot < GraphQL::Schema::Object }
1008
- if non_object_types.any?
1010
+ if !non_object_types.empty?
1009
1011
  raise ArgumentError, <<~ERR
1010
1012
  Only object type classes should be added as `orphan_types(...)`.
1011
1013
 
@@ -1022,7 +1024,7 @@ module GraphQL
1022
1024
 
1023
1025
  inherited_ot = find_inherited_value(:orphan_types, nil)
1024
1026
  if inherited_ot
1025
- if own_orphan_types.any?
1027
+ if !own_orphan_types.empty?
1026
1028
  inherited_ot + own_orphan_types
1027
1029
  else
1028
1030
  inherited_ot
@@ -1332,12 +1334,12 @@ module GraphQL
1332
1334
  # Add several directives at once
1333
1335
  # @param new_directives [Class]
1334
1336
  def directives(*new_directives)
1335
- if new_directives.any?
1337
+ if !new_directives.empty?
1336
1338
  new_directives.flatten.each { |d| directive(d) }
1337
1339
  end
1338
1340
 
1339
1341
  inherited_dirs = find_inherited_value(:directives, default_directives)
1340
- if own_directives.any?
1342
+ if !own_directives.empty?
1341
1343
  inherited_dirs.merge(own_directives)
1342
1344
  else
1343
1345
  inherited_dirs
@@ -1802,3 +1804,7 @@ module GraphQL
1802
1804
  end
1803
1805
  end
1804
1806
  end
1807
+
1808
+ require "graphql/schema/built_in_types"
1809
+ require "graphql/schema/loader"
1810
+ require "graphql/schema/printer"
@@ -16,7 +16,7 @@ module GraphQL
16
16
 
17
17
  def validate_arguments(node)
18
18
  argument_defns = node.arguments
19
- if argument_defns.any?
19
+ if !argument_defns.empty?
20
20
  args_by_name = Hash.new { |h, k| h[k] = [] }
21
21
  argument_defns.each { |a| args_by_name[a.name] << a }
22
22
  args_by_name.each do |name, defns|
@@ -25,7 +25,7 @@ module GraphQL
25
25
  def validate_field_selections(ast_node, resolved_type)
26
26
  msg = if resolved_type.nil?
27
27
  nil
28
- elsif ast_node.selections.any? && resolved_type.kind.leaf?
28
+ elsif !ast_node.selections.empty? && resolved_type.kind.leaf?
29
29
  selection_strs = ast_node.selections.map do |n|
30
30
  case n
31
31
  when GraphQL::Language::Nodes::InlineFragment
@@ -32,7 +32,7 @@ module GraphQL
32
32
 
33
33
  def on_document(node, parent)
34
34
  super
35
- if @schema_definition_nodes.any?
35
+ if !@schema_definition_nodes.empty?
36
36
  add_error(GraphQL::StaticValidation::NoDefinitionsArePresentError.new(%|Query cannot contain schema definitions|, nodes: @schema_definition_nodes))
37
37
  end
38
38
  end
@@ -24,7 +24,7 @@ module GraphQL
24
24
  .map!(&:name)
25
25
 
26
26
  missing_names = required_argument_names - present_argument_names
27
- if missing_names.any?
27
+ if !missing_names.empty?
28
28
  add_error(GraphQL::StaticValidation::RequiredArgumentsArePresentError.new(
29
29
  "#{ast_node.class.name.split("::").last} '#{ast_node.name}' is missing required arguments: #{missing_names.join(", ")}",
30
30
  nodes: ast_node,
@@ -21,7 +21,7 @@ module GraphQL
21
21
 
22
22
  DIRECTIVE_NODE_HOOKS.each do |method_name|
23
23
  define_method(method_name) do |node, parent|
24
- if node.directives.any?
24
+ if !node.directives.empty?
25
25
  validate_directive_location(node)
26
26
  end
27
27
  super(node, parent)
@@ -4,7 +4,7 @@ module GraphQL
4
4
  module VariableNamesAreUnique
5
5
  def on_operation_definition(node, parent)
6
6
  var_defns = node.variables
7
- if var_defns.any?
7
+ if !var_defns.empty?
8
8
  vars_by_name = Hash.new { |h, k| h[k] = [] }
9
9
  var_defns.each { |v| vars_by_name[v.name] << v }
10
10
  vars_by_name.each do |name, defns|
@@ -21,7 +21,7 @@ module GraphQL
21
21
  end
22
22
  node_values = node_values.select { |value| value.is_a? GraphQL::Language::Nodes::VariableIdentifier }
23
23
 
24
- if node_values.any?
24
+ if !node_values.empty?
25
25
  argument_owner = case parent
26
26
  when GraphQL::Language::Nodes::Field
27
27
  context.field_definition
@@ -171,7 +171,7 @@ module GraphQL
171
171
  events_by_fingerprint = @events[topic]
172
172
  object = nil
173
173
  events_by_fingerprint.each do |_fingerprint, events|
174
- if events.any? && events.first == initial_event
174
+ if !events.empty? && events.first == initial_event
175
175
  # The fingerprint has told us that this response should be shared by all subscribers,
176
176
  # so just run it once, then deliver the result to every subscriber
177
177
  first_event = events.first
@@ -291,7 +291,7 @@ module GraphQL
291
291
  end
292
292
  end
293
293
 
294
- if missing_arg_names.any?
294
+ if !missing_arg_names.empty?
295
295
  arg_owner_name = if arg_owner.is_a?(GraphQL::Schema::Field)
296
296
  arg_owner.path
297
297
  elsif arg_owner.is_a?(Class)
@@ -58,7 +58,7 @@ module GraphQL
58
58
  query_context[:current_field] = visible_field
59
59
  field_args = visible_field.coerce_arguments(graphql_result, arguments, query_context)
60
60
  field_args = schema.sync_lazy(field_args)
61
- if visible_field.extras.any?
61
+ if !visible_field.extras.empty?
62
62
  extra_args = {}
63
63
  visible_field.extras.each do |extra|
64
64
  extra_args[extra] = case extra
@@ -92,7 +92,7 @@ module GraphQL
92
92
  end
93
93
  graphql_result
94
94
  else
95
- unfiltered_type = schema.use_visibility_profile? ? schema.visibility.get_type(type_name) : schema.get_type(type_name) # rubocop:disable ContextIsPassedCop
95
+ unfiltered_type = schema.use_visibility_profile? ? schema.visibility.get_type(type_name) : schema.get_type(type_name) # rubocop:disable Development/ContextIsPassedCop
96
96
  if unfiltered_type
97
97
  raise TypeNotVisibleError.new(type_name: type_name)
98
98
  else
@@ -196,7 +196,7 @@ module GraphQL
196
196
  def edges
197
197
  # Assume that whatever authorization needed to happen
198
198
  # already happened at the connection level.
199
- current_runtime_state = Thread.current[:__graphql_runtime_info]
199
+ current_runtime_state = Fiber[:__graphql_runtime_info]
200
200
  query_runtime_state = current_runtime_state[context.query]
201
201
  query_runtime_state.was_authorized_by_scope_items = @object.was_authorized_by_scope_items?
202
202
  @object.edges
@@ -205,7 +205,7 @@ module GraphQL
205
205
  def nodes
206
206
  # Assume that whatever authorization needed to happen
207
207
  # already happened at the connection level.
208
- current_runtime_state = Thread.current[:__graphql_runtime_info]
208
+ current_runtime_state = Fiber[:__graphql_runtime_info]
209
209
  query_runtime_state = current_runtime_state[context.query]
210
210
  query_runtime_state.was_authorized_by_scope_items = @object.was_authorized_by_scope_items?
211
211
  @object.nodes
@@ -14,7 +14,7 @@ module GraphQL
14
14
  end
15
15
 
16
16
  def node
17
- current_runtime_state = Thread.current[:__graphql_runtime_info]
17
+ current_runtime_state = Fiber[:__graphql_runtime_info]
18
18
  query_runtime_state = current_runtime_state[context.query]
19
19
  query_runtime_state.was_authorized_by_scope_items = @object.was_authorized_by_scope_items?
20
20
  @object.node
data/lib/graphql/types.rb CHANGED
@@ -1,12 +1,19 @@
1
1
  # frozen_string_literal: true
2
- require "graphql/types/boolean"
3
- require "graphql/types/big_int"
4
- require "graphql/types/float"
5
- require "graphql/types/id"
6
- require "graphql/types/int"
7
- require "graphql/types/iso_8601_date"
8
- require "graphql/types/iso_8601_date_time"
9
- require "graphql/types/iso_8601_duration"
10
- require "graphql/types/json"
11
- require "graphql/types/string"
12
- require "graphql/types/relay"
2
+
3
+ module GraphQL
4
+ module Types
5
+ extend Autoload
6
+
7
+ autoload :Boolean, "graphql/types/boolean"
8
+ autoload :BigInt, "graphql/types/big_int"
9
+ autoload :Float, "graphql/types/float"
10
+ autoload :ID, "graphql/types/id"
11
+ autoload :Int, "graphql/types/int"
12
+ autoload :JSON, "graphql/types/json"
13
+ autoload :String, "graphql/types/string"
14
+ autoload :ISO8601Date, "graphql/types/iso_8601_date"
15
+ autoload :ISO8601DateTime, "graphql/types/iso_8601_date_time"
16
+ autoload :ISO8601Duration, "graphql/types/iso_8601_duration"
17
+ autoload :Relay, "graphql/types/relay"
18
+ end
19
+ end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module GraphQL
3
- VERSION = "2.4.4"
3
+ VERSION = "2.4.5"
4
4
  end
data/lib/graphql.rb CHANGED
@@ -5,8 +5,18 @@ require "set"
5
5
  require "singleton"
6
6
  require "forwardable"
7
7
  require "fiber/storage"
8
+ require "graphql/autoload"
8
9
 
9
10
  module GraphQL
11
+ extend Autoload
12
+
13
+ # Load all `autoload`-configured classes, and also eager-load dependents who have autoloads of their own.
14
+ def self.eager_load!
15
+ super
16
+ Query.eager_load!
17
+ Types.eager_load!
18
+ end
19
+
10
20
  class Error < StandardError
11
21
  end
12
22
 
@@ -71,56 +81,79 @@ This is probably a bug in GraphQL-Ruby, please report this error on GitHub: http
71
81
  class << self
72
82
  # If true, the parser should raise when an integer or float is followed immediately by an identifier (instead of a space or punctuation)
73
83
  attr_accessor :reject_numbers_followed_by_names
84
+
85
+ # If `production?` is detected but `eager_load!` wasn't called, emit a warning.
86
+ # @return [void]
87
+ def ensure_eager_load!
88
+ if production? && !eager_loading?
89
+ warn <<~WARNING
90
+ GraphQL-Ruby thinks this is a production deployment but didn't eager-load its constants. Address this by:
91
+
92
+ - Calling `GraphQL.eager_load!` in a production-only initializer or setup hook
93
+ - Assign `GraphQL.env = "..."` to something _other_ than `"production"` (for example, `GraphQL.env = "development"`)
94
+
95
+ More details: https://graphql-ruby.org/schema/definition#production-considerations
96
+ WARNING
97
+ end
98
+ end
99
+
100
+ attr_accessor :env
101
+
102
+ private
103
+
104
+ # Detect whether this is a production deployment or not
105
+ def production?
106
+ if env
107
+ # Manually assigned to production?
108
+ env == "production"
109
+ else
110
+ (detected_env = ENV["RACK_ENV"] || ENV["RAILS_ENV"] || ENV["HANAMI_ENV"] || ENV["APP_ENV"]) && detected_env.to_s.downcase == "production"
111
+ end
112
+ end
74
113
  end
75
114
 
76
115
  self.reject_numbers_followed_by_names = false
77
- end
78
116
 
79
- # Order matters for these:
80
-
81
- require "graphql/execution_error"
82
- require "graphql/runtime_type_error"
83
- require "graphql/unresolved_type_error"
84
- require "graphql/invalid_null_error"
85
- require "graphql/analysis_error"
86
- require "graphql/coercion_error"
87
- require "graphql/invalid_name_error"
88
- require "graphql/integer_decoding_error"
89
- require "graphql/integer_encoding_error"
90
- require "graphql/string_encoding_error"
91
- require "graphql/date_encoding_error"
92
- require "graphql/duration_encoding_error"
93
- require "graphql/type_kinds"
94
- require "graphql/name_validator"
95
- require "graphql/language"
96
-
97
- require_relative "./graphql/railtie" if defined? Rails::Railtie
98
-
99
- require "graphql/analysis"
100
- require "graphql/tracing"
101
- require "graphql/dig"
102
- require "graphql/execution"
103
- require "graphql/pagination"
104
- require "graphql/schema"
105
- require "graphql/query"
106
- require "graphql/dataloader"
107
- require "graphql/types"
108
- require "graphql/static_validation"
109
- require "graphql/execution"
110
- require "graphql/schema/built_in_types"
111
- require "graphql/schema/loader"
112
- require "graphql/schema/printer"
113
- require "graphql/introspection"
114
- require "graphql/relay"
117
+ autoload :ExecutionError, "graphql/execution_error"
118
+ autoload :RuntimeTypeError, "graphql/runtime_type_error"
119
+ autoload :UnresolvedTypeError, "graphql/unresolved_type_error"
120
+ autoload :InvalidNullError, "graphql/invalid_null_error"
121
+ autoload :AnalysisError, "graphql/analysis_error"
122
+ autoload :CoercionError, "graphql/coercion_error"
123
+ autoload :InvalidNameError, "graphql/invalid_name_error"
124
+ autoload :IntegerDecodingError, "graphql/integer_decoding_error"
125
+ autoload :IntegerEncodingError, "graphql/integer_encoding_error"
126
+ autoload :StringEncodingError, "graphql/string_encoding_error"
127
+ autoload :DateEncodingError, "graphql/date_encoding_error"
128
+ autoload :DurationEncodingError, "graphql/duration_encoding_error"
129
+ autoload :TypeKinds, "graphql/type_kinds"
130
+ autoload :NameValidator, "graphql/name_validator"
131
+ autoload :Language, "graphql/language"
132
+
133
+ autoload :Analysis, "graphql/analysis"
134
+ autoload :Tracing, "graphql/tracing"
135
+ autoload :Dig, "graphql/dig"
136
+ autoload :Execution, "graphql/execution"
137
+ autoload :Pagination, "graphql/pagination"
138
+ autoload :Schema, "graphql/schema"
139
+ autoload :Query, "graphql/query"
140
+ autoload :Dataloader, "graphql/dataloader"
141
+ autoload :Types, "graphql/types"
142
+ autoload :StaticValidation, "graphql/static_validation"
143
+ autoload :Execution, "graphql/execution"
144
+ autoload :Introspection, "graphql/introspection"
145
+ autoload :Relay, "graphql/relay"
146
+ autoload :Subscriptions, "graphql/subscriptions"
147
+ autoload :ParseError, "graphql/parse_error"
148
+ autoload :Backtrace, "graphql/backtrace"
149
+
150
+ autoload :UnauthorizedError, "graphql/unauthorized_error"
151
+ autoload :UnauthorizedEnumValueError, "graphql/unauthorized_enum_value_error"
152
+ autoload :UnauthorizedFieldError, "graphql/unauthorized_field_error"
153
+ autoload :LoadApplicationObjectFailedError, "graphql/load_application_object_failed_error"
154
+ autoload :Testing, "graphql/testing"
155
+ autoload :Current, "graphql/current"
156
+ end
115
157
 
116
158
  require "graphql/version"
117
- require "graphql/subscriptions"
118
- require "graphql/parse_error"
119
- require "graphql/backtrace"
120
-
121
- require "graphql/unauthorized_error"
122
- require "graphql/unauthorized_enum_value_error"
123
- require "graphql/unauthorized_field_error"
124
- require "graphql/load_application_object_failed_error"
125
- require "graphql/testing"
126
- require "graphql/current"
159
+ require "graphql/railtie" if defined? Rails::Railtie
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
4
+ version: 2.4.5
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-18 00:00:00.000000000 Z
11
+ date: 2024-12-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: base64
@@ -328,6 +328,7 @@ files:
328
328
  - lib/graphql/analysis/query_depth.rb
329
329
  - lib/graphql/analysis/visitor.rb
330
330
  - lib/graphql/analysis_error.rb
331
+ - lib/graphql/autoload.rb
331
332
  - lib/graphql/backtrace.rb
332
333
  - lib/graphql/backtrace/inspect_result.rb
333
334
  - lib/graphql/backtrace/table.rb