graphql 2.4.3 → 2.4.13

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 (141) hide show
  1. checksums.yaml +4 -4
  2. data/lib/graphql/analysis/analyzer.rb +2 -1
  3. data/lib/graphql/analysis/visitor.rb +38 -41
  4. data/lib/graphql/analysis.rb +15 -12
  5. data/lib/graphql/autoload.rb +38 -0
  6. data/lib/graphql/backtrace/table.rb +95 -55
  7. data/lib/graphql/backtrace.rb +1 -19
  8. data/lib/graphql/current.rb +6 -1
  9. data/lib/graphql/dashboard/statics/bootstrap-5.3.3.min.css +6 -0
  10. data/lib/graphql/dashboard/statics/bootstrap-5.3.3.min.js +7 -0
  11. data/lib/graphql/dashboard/statics/dashboard.css +3 -0
  12. data/lib/graphql/dashboard/statics/dashboard.js +78 -0
  13. data/lib/graphql/dashboard/statics/header-icon.png +0 -0
  14. data/lib/graphql/dashboard/statics/icon.png +0 -0
  15. data/lib/graphql/dashboard/views/graphql/dashboard/landings/show.html.erb +18 -0
  16. data/lib/graphql/dashboard/views/graphql/dashboard/traces/index.html.erb +63 -0
  17. data/lib/graphql/dashboard/views/layouts/graphql/dashboard/application.html.erb +60 -0
  18. data/lib/graphql/dashboard.rb +142 -0
  19. data/lib/graphql/dataloader/active_record_association_source.rb +64 -0
  20. data/lib/graphql/dataloader/active_record_source.rb +26 -0
  21. data/lib/graphql/dataloader/async_dataloader.rb +21 -9
  22. data/lib/graphql/dataloader/null_dataloader.rb +1 -1
  23. data/lib/graphql/dataloader/source.rb +3 -3
  24. data/lib/graphql/dataloader.rb +43 -14
  25. data/lib/graphql/execution/interpreter/resolve.rb +3 -3
  26. data/lib/graphql/execution/interpreter/runtime/graphql_result.rb +11 -4
  27. data/lib/graphql/execution/interpreter/runtime.rb +67 -40
  28. data/lib/graphql/execution/interpreter.rb +16 -6
  29. data/lib/graphql/execution/multiplex.rb +0 -4
  30. data/lib/graphql/introspection/directive_location_enum.rb +1 -1
  31. data/lib/graphql/invalid_name_error.rb +1 -1
  32. data/lib/graphql/invalid_null_error.rb +5 -15
  33. data/lib/graphql/language/cache.rb +13 -0
  34. data/lib/graphql/language/document_from_schema_definition.rb +8 -7
  35. data/lib/graphql/language/lexer.rb +11 -4
  36. data/lib/graphql/language/nodes.rb +3 -0
  37. data/lib/graphql/language/parser.rb +2 -2
  38. data/lib/graphql/language/printer.rb +8 -8
  39. data/lib/graphql/language/static_visitor.rb +37 -33
  40. data/lib/graphql/language/visitor.rb +59 -55
  41. data/lib/graphql/pagination/connection.rb +1 -1
  42. data/lib/graphql/query/context/scoped_context.rb +1 -1
  43. data/lib/graphql/query/context.rb +6 -5
  44. data/lib/graphql/query/variable_validation_error.rb +1 -1
  45. data/lib/graphql/query.rb +20 -22
  46. data/lib/graphql/railtie.rb +7 -0
  47. data/lib/graphql/schema/addition.rb +1 -1
  48. data/lib/graphql/schema/argument.rb +3 -5
  49. data/lib/graphql/schema/build_from_definition.rb +8 -7
  50. data/lib/graphql/schema/directive/flagged.rb +1 -1
  51. data/lib/graphql/schema/directive.rb +2 -2
  52. data/lib/graphql/schema/enum.rb +36 -1
  53. data/lib/graphql/schema/enum_value.rb +1 -1
  54. data/lib/graphql/schema/field/scope_extension.rb +1 -1
  55. data/lib/graphql/schema/field.rb +12 -12
  56. data/lib/graphql/schema/field_extension.rb +1 -1
  57. data/lib/graphql/schema/has_single_input_argument.rb +3 -1
  58. data/lib/graphql/schema/input_object.rb +70 -34
  59. data/lib/graphql/schema/interface.rb +3 -2
  60. data/lib/graphql/schema/loader.rb +1 -1
  61. data/lib/graphql/schema/member/has_arguments.rb +25 -17
  62. data/lib/graphql/schema/member/has_dataloader.rb +60 -0
  63. data/lib/graphql/schema/member/has_directives.rb +4 -4
  64. data/lib/graphql/schema/member/has_fields.rb +19 -1
  65. data/lib/graphql/schema/member/has_interfaces.rb +5 -5
  66. data/lib/graphql/schema/member/has_validators.rb +1 -1
  67. data/lib/graphql/schema/member/scoped.rb +1 -1
  68. data/lib/graphql/schema/member/type_system_helpers.rb +1 -1
  69. data/lib/graphql/schema/member.rb +1 -0
  70. data/lib/graphql/schema/object.rb +25 -8
  71. data/lib/graphql/schema/relay_classic_mutation.rb +0 -1
  72. data/lib/graphql/schema/resolver.rb +11 -10
  73. data/lib/graphql/schema/subscription.rb +52 -6
  74. data/lib/graphql/schema/union.rb +1 -1
  75. data/lib/graphql/schema/validator/required_validator.rb +23 -6
  76. data/lib/graphql/schema/validator.rb +1 -1
  77. data/lib/graphql/schema/visibility/migration.rb +1 -0
  78. data/lib/graphql/schema/visibility/profile.rb +69 -237
  79. data/lib/graphql/schema/visibility/visit.rb +190 -0
  80. data/lib/graphql/schema/visibility.rb +169 -28
  81. data/lib/graphql/schema/warden.rb +18 -5
  82. data/lib/graphql/schema.rb +90 -43
  83. data/lib/graphql/static_validation/rules/argument_names_are_unique.rb +1 -1
  84. data/lib/graphql/static_validation/rules/fields_have_appropriate_selections.rb +1 -1
  85. data/lib/graphql/static_validation/rules/fields_will_merge.rb +1 -1
  86. data/lib/graphql/static_validation/rules/no_definitions_are_present.rb +1 -1
  87. data/lib/graphql/static_validation/rules/required_arguments_are_present.rb +1 -1
  88. data/lib/graphql/static_validation/rules/unique_directives_per_location.rb +1 -1
  89. data/lib/graphql/static_validation/rules/variable_names_are_unique.rb +1 -1
  90. data/lib/graphql/static_validation/rules/variable_usages_are_allowed.rb +1 -1
  91. data/lib/graphql/static_validation/validation_context.rb +1 -0
  92. data/lib/graphql/static_validation/validator.rb +6 -1
  93. data/lib/graphql/subscriptions/action_cable_subscriptions.rb +1 -1
  94. data/lib/graphql/subscriptions/default_subscription_resolve_extension.rb +12 -10
  95. data/lib/graphql/subscriptions/event.rb +12 -1
  96. data/lib/graphql/subscriptions/serialize.rb +1 -1
  97. data/lib/graphql/subscriptions.rb +1 -1
  98. data/lib/graphql/testing/helpers.rb +2 -2
  99. data/lib/graphql/tracing/active_support_notifications_trace.rb +7 -3
  100. data/lib/graphql/tracing/active_support_notifications_tracing.rb +1 -1
  101. data/lib/graphql/tracing/appoptics_trace.rb +9 -1
  102. data/lib/graphql/tracing/appoptics_tracing.rb +2 -0
  103. data/lib/graphql/tracing/appsignal_trace.rb +12 -0
  104. data/lib/graphql/tracing/appsignal_tracing.rb +2 -0
  105. data/lib/graphql/tracing/call_legacy_tracers.rb +66 -0
  106. data/lib/graphql/tracing/data_dog_trace.rb +11 -0
  107. data/lib/graphql/tracing/data_dog_tracing.rb +2 -0
  108. data/lib/graphql/tracing/detailed_trace/memory_backend.rb +60 -0
  109. data/lib/graphql/tracing/detailed_trace/redis_backend.rb +72 -0
  110. data/lib/graphql/tracing/detailed_trace.rb +93 -0
  111. data/lib/graphql/tracing/legacy_hooks_trace.rb +1 -0
  112. data/lib/graphql/tracing/legacy_trace.rb +4 -61
  113. data/lib/graphql/tracing/new_relic_trace.rb +164 -41
  114. data/lib/graphql/tracing/new_relic_tracing.rb +2 -0
  115. data/lib/graphql/tracing/notifications_trace.rb +4 -0
  116. data/lib/graphql/tracing/notifications_tracing.rb +2 -0
  117. data/lib/graphql/tracing/null_trace.rb +9 -0
  118. data/lib/graphql/tracing/perfetto_trace/trace.proto +141 -0
  119. data/lib/graphql/tracing/perfetto_trace/trace_pb.rb +33 -0
  120. data/lib/graphql/tracing/perfetto_trace.rb +737 -0
  121. data/lib/graphql/tracing/platform_trace.rb +5 -0
  122. data/lib/graphql/tracing/prometheus_trace/graphql_collector.rb +2 -0
  123. data/lib/graphql/tracing/prometheus_trace.rb +31 -0
  124. data/lib/graphql/tracing/prometheus_tracing.rb +2 -0
  125. data/lib/graphql/tracing/scout_trace.rb +11 -0
  126. data/lib/graphql/tracing/scout_tracing.rb +2 -0
  127. data/lib/graphql/tracing/sentry_trace.rb +11 -0
  128. data/lib/graphql/tracing/statsd_trace.rb +15 -0
  129. data/lib/graphql/tracing/statsd_tracing.rb +2 -0
  130. data/lib/graphql/tracing/trace.rb +128 -1
  131. data/lib/graphql/tracing.rb +30 -30
  132. data/lib/graphql/types/relay/connection_behaviors.rb +3 -3
  133. data/lib/graphql/types/relay/edge_behaviors.rb +2 -2
  134. data/lib/graphql/types.rb +18 -11
  135. data/lib/graphql/version.rb +1 -1
  136. data/lib/graphql.rb +55 -47
  137. metadata +152 -10
  138. data/lib/graphql/backtrace/inspect_result.rb +0 -38
  139. data/lib/graphql/backtrace/trace.rb +0 -93
  140. data/lib/graphql/backtrace/tracer.rb +0 -80
  141. data/lib/graphql/schema/null_mask.rb +0 -11
@@ -39,6 +39,9 @@ module GraphQL
39
39
  include(BaseKeyCache)
40
40
  }
41
41
  child_class.const_set(:KeyCache, key_methods_class)
42
+
43
+ # rubocop:disable Development/NoEvalCop This eval takes static inputs at load-time
44
+
42
45
  [:execute_field, :execute_field_lazy].each do |field_trace_method|
43
46
  if !child_class.method_defined?(field_trace_method)
44
47
  child_class.module_eval <<-RUBY, __FILE__, __LINE__
@@ -91,6 +94,8 @@ module GraphQL
91
94
  end
92
95
  RUBY
93
96
  end
97
+
98
+ # rubocop:enable Development/NoEvalCop
94
99
  end
95
100
  end
96
101
 
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "graphql/tracing"
4
+
3
5
  module GraphQL
4
6
  module Tracing
5
7
  module PrometheusTrace
@@ -1,8 +1,35 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "graphql/tracing/platform_trace"
4
+
3
5
  module GraphQL
4
6
  module Tracing
7
+ # A tracer for reporting GraphQL-Ruby times to Prometheus.
8
+ #
9
+ # The PrometheusExporter server must be run with a custom type collector that extends `GraphQL::Tracing::PrometheusTracing::GraphQLCollector`.
10
+ #
11
+ # @example Adding this trace to your schema
12
+ # require 'prometheus_exporter/client'
13
+ #
14
+ # class MySchema < GraphQL::Schema
15
+ # trace_with GraphQL::Tracing::PrometheusTrace
16
+ # end
17
+ #
18
+ # @example Running a custom type collector
19
+ # # lib/graphql_collector.rb
20
+ # if defined?(PrometheusExporter::Server)
21
+ # require 'graphql/tracing'
22
+ #
23
+ # class GraphQLCollector < GraphQL::Tracing::PrometheusTrace::GraphQLCollector
24
+ # end
25
+ # end
26
+ #
27
+ # # Then run:
28
+ # # bundle exec prometheus_exporter -a lib/graphql_collector.rb
5
29
  module PrometheusTrace
30
+ if defined?(PrometheusExporter::Server)
31
+ autoload :GraphQLCollector, "graphql/tracing/prometheus_trace/graphql_collector"
32
+ end
6
33
  include PlatformTrace
7
34
 
8
35
  def initialize(client: PrometheusExporter::Client.default, keys_whitelist: ["execute_field", "execute_field_lazy"], collector_type: "graphql", **rest)
@@ -13,6 +40,8 @@ module GraphQL
13
40
  super(**rest)
14
41
  end
15
42
 
43
+ # rubocop:disable Development/NoEvalCop This eval takes static inputs at load-time
44
+
16
45
  {
17
46
  'lex' => "graphql.lex",
18
47
  'parse' => "graphql.parse",
@@ -30,6 +59,8 @@ module GraphQL
30
59
  RUBY
31
60
  end
32
61
 
62
+ # rubocop:enable Development/NoEvalCop
63
+
33
64
  def platform_execute_field(platform_key, &block)
34
65
  instrument_prometheus_execution(platform_key, "execute_field", &block)
35
66
  end
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "graphql/tracing/platform_tracing"
4
+
3
5
  module GraphQL
4
6
  module Tracing
5
7
  class PrometheusTracing < PlatformTracing
@@ -1,7 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "graphql/tracing/platform_trace"
4
+
3
5
  module GraphQL
4
6
  module Tracing
7
+ # A tracer for sending GraphQL-Ruby times to Scout
8
+ #
9
+ # @example Adding this tracer to your schema
10
+ # class MySchema < GraphQL::Schema
11
+ # trace_with GraphQL::Tracing::ScoutTrace
12
+ # end
5
13
  module ScoutTrace
6
14
  include PlatformTrace
7
15
 
@@ -16,6 +24,8 @@ module GraphQL
16
24
  super
17
25
  end
18
26
 
27
+ # rubocop:disable Development/NoEvalCop This eval takes static inputs at load-time
28
+
19
29
  {
20
30
  "lex" => "lex.graphql",
21
31
  "parse" => "parse.graphql",
@@ -45,6 +55,7 @@ module GraphQL
45
55
  end
46
56
  RUBY
47
57
  end
58
+ # rubocop:enable Development/NoEvalCop
48
59
 
49
60
  def platform_execute_field(platform_key, &block)
50
61
  self.class.instrument("GraphQL", platform_key, INSTRUMENT_OPTS, &block)
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "graphql/tracing/platform_tracing"
4
+
3
5
  module GraphQL
4
6
  module Tracing
5
7
  class ScoutTracing < PlatformTracing
@@ -1,7 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "graphql/tracing/platform_trace"
4
+
3
5
  module GraphQL
4
6
  module Tracing
7
+ # A tracer for reporting GraphQL-Ruby times to Sentry.
8
+ # @example Installing the tracer
9
+ # class MySchema < GraphQL::Schema
10
+ # trace_with GraphQL::Tracing::SentryTrace
11
+ # end
5
12
  module SentryTrace
6
13
  include PlatformTrace
7
14
 
@@ -23,6 +30,8 @@ module GraphQL
23
30
  instrument_sentry_execution("graphql.execute", "execute_query", data) { super }
24
31
  end
25
32
 
33
+ # rubocop:disable Development/NoEvalCop This eval takes static inputs at load-time
34
+
26
35
  {
27
36
  "lex" => "graphql.lex",
28
37
  "parse" => "graphql.parse",
@@ -39,6 +48,8 @@ module GraphQL
39
48
  RUBY
40
49
  end
41
50
 
51
+ # rubocop:enable Development/NoEvalCop
52
+
42
53
  def platform_execute_field(platform_key, &block)
43
54
  instrument_sentry_execution(platform_key, "execute_field", &block)
44
55
  end
@@ -1,7 +1,18 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "graphql/tracing/platform_trace"
4
+
3
5
  module GraphQL
4
6
  module Tracing
7
+ # A tracer for reporting GraphQL-Ruby times to Statsd.
8
+ # Passing any Statsd client that implements `.time(name) { ... }` will work.
9
+ #
10
+ # @example Installing this tracer
11
+ # # eg:
12
+ # # $statsd = Statsd.new 'localhost', 9125
13
+ # class MySchema < GraphQL::Schema
14
+ # use GraphQL::Tracing::StatsdTrace, statsd: $statsd
15
+ # end
5
16
  module StatsdTrace
6
17
  include PlatformTrace
7
18
 
@@ -11,6 +22,8 @@ module GraphQL
11
22
  super(**rest)
12
23
  end
13
24
 
25
+ # rubocop:disable Development/NoEvalCop This eval takes static inputs at load-time
26
+
14
27
  {
15
28
  'lex' => "graphql.lex",
16
29
  'parse' => "graphql.parse",
@@ -30,6 +43,8 @@ module GraphQL
30
43
  RUBY
31
44
  end
32
45
 
46
+ # rubocop:enable Development/NoEvalCop
47
+
33
48
  def platform_execute_field(platform_key, &block)
34
49
  @statsd.time(platform_key, &block)
35
50
  end
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "graphql/tracing/platform_tracing"
4
+
3
5
  module GraphQL
4
6
  module Tracing
5
7
  class StatsdTracing < PlatformTracing
@@ -1,11 +1,14 @@
1
1
  # frozen_string_literal: true
2
+
3
+ require "graphql/tracing"
4
+
2
5
  module GraphQL
3
6
  module Tracing
4
7
  # This is the base class for a `trace` instance whose methods are called during query execution.
5
8
  # "Trace modes" are subclasses of this with custom tracing modules mixed in.
6
9
  #
7
10
  # A trace module may implement any of the methods on `Trace`, being sure to call `super`
8
- # to continue any tracing hooks and call the actual runtime behavior. See {GraphQL::Backtrace::Trace} for example.
11
+ # to continue any tracing hooks and call the actual runtime behavior.
9
12
  #
10
13
  class Trace
11
14
  # @param multiplex [GraphQL::Execution::Multiplex, nil]
@@ -20,6 +23,14 @@ module GraphQL
20
23
  yield
21
24
  end
22
25
 
26
+ # @param query_str [String]
27
+ # @return [void]
28
+ def begin_parse(query_str); end;
29
+ # @param query_str [String]
30
+ # @return [void]
31
+ def end_parse(query_str); end;
32
+ # @param query_string [String]
33
+ # @return [void]
23
34
  def parse(query_string:)
24
35
  yield
25
36
  end
@@ -28,6 +39,22 @@ module GraphQL
28
39
  yield
29
40
  end
30
41
 
42
+ def begin_validate(query, validate)
43
+ end
44
+
45
+ def end_validate(query, validate, errors)
46
+ end
47
+
48
+ # @param multiplex [GraphQL::Execution::Multiplex]
49
+ # @param analyzers [Array<Class>]
50
+ # @return [void]
51
+ def begin_analyze_multiplex(multiplex, analyzers); end
52
+ # @param multiplex [GraphQL::Execution::Multiplex]
53
+ # @param analyzers [Array<Class>]
54
+ # @return [void]
55
+ def end_analyze_multiplex(multiplex, analyzers); end
56
+ # @param multiplex [GraphQL::Execution::Multiplex]
57
+ # @return [void]
31
58
  def analyze_multiplex(multiplex:)
32
59
  yield
33
60
  end
@@ -36,6 +63,20 @@ module GraphQL
36
63
  yield
37
64
  end
38
65
 
66
+ # This is the first event in the tracing lifecycle.
67
+ # Every Query is technically run _inside_ a {GraphQL::Multiplex}.
68
+ # @param multiplex [GraphQL::Execution::Multiplex]
69
+ # @return [void]
70
+ def begin_execute_multiplex(multiplex); end;
71
+
72
+ # This is the last event of the tracing lifecycle.
73
+ # @param multiplex [GraphQL::Execution::Multiplex]
74
+ # @return [void]
75
+ def end_execute_multiplex(multiplex); end;
76
+
77
+ # This wraps an entire `.execute` call.
78
+ # @param multiplex [GraphQL::Execution::Multiplex]
79
+ # @return [void]
39
80
  def execute_multiplex(multiplex:)
40
81
  yield
41
82
  end
@@ -48,6 +89,20 @@ module GraphQL
48
89
  yield
49
90
  end
50
91
 
92
+ # GraphQL is about to resolve this field
93
+ # @param field [GraphQL::Schema::Field]
94
+ # @param object [GraphQL::Schema::Object]
95
+ # @param arguments [Hash]
96
+ # @param query [GraphQL::Query]
97
+ def begin_execute_field(field, object, arguments, query); end
98
+ # GraphQL just finished resolving this field
99
+ # @param field [GraphQL::Schema::Field]
100
+ # @param object [GraphQL::Schema::Object]
101
+ # @param arguments [Hash]
102
+ # @param query [GraphQL::Query]
103
+ # @param result [Object]
104
+ def end_execute_field(field, object, arguments, query, result); end
105
+
51
106
  def execute_field(field:, query:, ast_node:, arguments:, object:)
52
107
  yield
53
108
  end
@@ -60,6 +115,22 @@ module GraphQL
60
115
  yield
61
116
  end
62
117
 
118
+ # A call to `.authorized?` is starting
119
+ # @param type [Class<GraphQL::Schema::Object>]
120
+ # @param object [Object]
121
+ # @param context [GraphQL::Query::Context]
122
+ # @return [void]
123
+ def begin_authorized(type, object, context)
124
+ end
125
+ # A call to `.authorized?` just finished
126
+ # @param type [Class<GraphQL::Schema::Object>]
127
+ # @param object [Object]
128
+ # @param context [GraphQL::Query::Context]
129
+ # @param authorized_result [Boolean]
130
+ # @return [void]
131
+ def end_authorized(type, object, context, authorized_result)
132
+ end
133
+
63
134
  def authorized_lazy(query:, type:, object:)
64
135
  yield
65
136
  end
@@ -71,6 +142,62 @@ module GraphQL
71
142
  def resolve_type_lazy(query:, type:, object:)
72
143
  yield
73
144
  end
145
+
146
+ # A call to `.resolve_type` is starting
147
+ # @param type [Class<GraphQL::Schema::Union>, Module<GraphQL::Schema::Interface>]
148
+ # @param value [Object]
149
+ # @param context [GraphQL::Query::Context]
150
+ # @return [void]
151
+ def begin_resolve_type(type, value, context)
152
+ end
153
+
154
+ # A call to `.resolve_type` just ended
155
+ # @param type [Class<GraphQL::Schema::Union>, Module<GraphQL::Schema::Interface>]
156
+ # @param value [Object]
157
+ # @param context [GraphQL::Query::Context]
158
+ # @param resolved_type [Class<GraphQL::Schema::Object>]
159
+ # @return [void]
160
+ def end_resolve_type(type, value, context, resolved_type)
161
+ end
162
+
163
+ # A dataloader run is starting
164
+ # @param dataloader [GraphQL::Dataloader]
165
+ # @return [void]
166
+ def begin_dataloader(dataloader); end
167
+ # A dataloader run has ended
168
+ # @param dataloder [GraphQL::Dataloader]
169
+ # @return [void]
170
+ def end_dataloader(dataloader); end
171
+
172
+ # A source with pending keys is about to fetch
173
+ # @param source [GraphQL::Dataloader::Source]
174
+ # @return [void]
175
+ def begin_dataloader_source(source); end
176
+ # A fetch call has just ended
177
+ # @param source [GraphQL::Dataloader::Source]
178
+ # @return [void]
179
+ def end_dataloader_source(source); end
180
+
181
+ # Called when Dataloader spins up a new fiber for GraphQL execution
182
+ # @param jobs [Array<#call>] Execution steps to run
183
+ # @return [void]
184
+ def dataloader_spawn_execution_fiber(jobs); end
185
+ # Called when Dataloader spins up a new fiber for fetching data
186
+ # @param pending_sources [GraphQL::Dataloader::Source] Instances with pending keys
187
+ # @return [void]
188
+ def dataloader_spawn_source_fiber(pending_sources); end
189
+ # Called when an execution or source fiber terminates
190
+ # @return [void]
191
+ def dataloader_fiber_exit; end
192
+
193
+ # Called when a Dataloader fiber is paused to wait for data
194
+ # @param source [GraphQL::Dataloader::Source] The Source whose `load` call initiated this `yield`
195
+ # @return [void]
196
+ def dataloader_fiber_yield(source); end
197
+ # Called when a Dataloader fiber is resumed because data has been loaded
198
+ # @param source [GraphQL::Dataloader::Source] The Source whose `load` call previously caused this Fiber to wait
199
+ # @return [void]
200
+ def dataloader_fiber_resume(source); end
74
201
  end
75
202
  end
76
203
  end
@@ -1,38 +1,38 @@
1
1
  # frozen_string_literal: true
2
- require "graphql/tracing/trace"
3
- require "graphql/tracing/legacy_trace"
4
- require "graphql/tracing/legacy_hooks_trace"
5
2
 
6
- # Legacy tracing:
7
- require "graphql/tracing/active_support_notifications_tracing"
8
- require "graphql/tracing/platform_tracing"
9
- require "graphql/tracing/appoptics_tracing"
10
- require "graphql/tracing/appsignal_tracing"
11
- require "graphql/tracing/data_dog_tracing"
12
- require "graphql/tracing/new_relic_tracing"
13
- require "graphql/tracing/scout_tracing"
14
- require "graphql/tracing/statsd_tracing"
15
- require "graphql/tracing/prometheus_tracing"
16
-
17
- # New Tracing:
18
- require "graphql/tracing/active_support_notifications_trace"
19
- require "graphql/tracing/platform_trace"
20
- require "graphql/tracing/appoptics_trace"
21
- require "graphql/tracing/appsignal_trace"
22
- require "graphql/tracing/data_dog_trace"
23
- require "graphql/tracing/new_relic_trace"
24
- require "graphql/tracing/notifications_trace"
25
- require "graphql/tracing/sentry_trace"
26
- require "graphql/tracing/scout_trace"
27
- require "graphql/tracing/statsd_trace"
28
- require "graphql/tracing/prometheus_trace"
29
- if defined?(PrometheusExporter::Server)
30
- require "graphql/tracing/prometheus_trace/graphql_collector"
31
- end
32
3
 
33
4
  module GraphQL
34
5
  module Tracing
35
- NullTrace = Trace.new
6
+ autoload :Trace, "graphql/tracing/trace"
7
+ autoload :CallLegacyTracers, "graphql/tracing/call_legacy_tracers"
8
+ autoload :LegacyTrace, "graphql/tracing/legacy_trace"
9
+ autoload :LegacyHooksTrace, "graphql/tracing/legacy_hooks_trace"
10
+ autoload :NullTrace, "graphql/tracing/null_trace"
11
+
12
+ autoload :ActiveSupportNotificationsTracing, "graphql/tracing/active_support_notifications_tracing"
13
+ autoload :PlatformTracing, "graphql/tracing/platform_tracing"
14
+ autoload :AppOpticsTracing, "graphql/tracing/appoptics_tracing"
15
+ autoload :AppsignalTracing, "graphql/tracing/appsignal_tracing"
16
+ autoload :DataDogTracing, "graphql/tracing/data_dog_tracing"
17
+ autoload :NewRelicTracing, "graphql/tracing/new_relic_tracing"
18
+ autoload :NotificationsTracing, "graphql/tracing/notifications_tracing"
19
+ autoload :ScoutTracing, "graphql/tracing/scout_tracing"
20
+ autoload :StatsdTracing, "graphql/tracing/statsd_tracing"
21
+ autoload :PrometheusTracing, "graphql/tracing/prometheus_tracing"
22
+
23
+ autoload :ActiveSupportNotificationsTrace, "graphql/tracing/active_support_notifications_trace"
24
+ autoload :PlatformTrace, "graphql/tracing/platform_trace"
25
+ autoload :AppOpticsTrace, "graphql/tracing/appoptics_trace"
26
+ autoload :AppsignalTrace, "graphql/tracing/appsignal_trace"
27
+ autoload :DataDogTrace, "graphql/tracing/data_dog_trace"
28
+ autoload :NewRelicTrace, "graphql/tracing/new_relic_trace"
29
+ autoload :NotificationsTrace, "graphql/tracing/notifications_trace"
30
+ autoload :SentryTrace, "graphql/tracing/sentry_trace"
31
+ autoload :ScoutTrace, "graphql/tracing/scout_trace"
32
+ autoload :StatsdTrace, "graphql/tracing/statsd_trace"
33
+ autoload :PrometheusTrace, "graphql/tracing/prometheus_trace"
34
+ autoload :PerfettoTrace, "graphql/tracing/perfetto_trace"
35
+ autoload :DetailedTrace, "graphql/tracing/detailed_trace"
36
36
 
37
37
  # Objects may include traceable to gain a `.trace(...)` method.
38
38
  # The object must have a `@tracers` ivar of type `Array<<#trace(k, d, &b)>>`.
@@ -13,7 +13,7 @@ module GraphQL
13
13
  child_class.node_nullable(true)
14
14
  child_class.edges_nullable(true)
15
15
  child_class.edge_nullable(true)
16
- child_class.module_eval {
16
+ child_class.module_exec {
17
17
  self.edge_type = nil
18
18
  self.node_type = nil
19
19
  self.edge_class = nil
@@ -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
@@ -8,13 +8,13 @@ module GraphQL
8
8
  child_class.description("An edge in a connection.")
9
9
  child_class.field(:cursor, String, null: false, description: "A cursor for use in pagination.")
10
10
  child_class.extend(ClassMethods)
11
- child_class.class_eval { self.node_type = nil }
11
+ child_class.class_exec { self.node_type = nil }
12
12
  child_class.node_nullable(true)
13
13
  child_class.default_broadcastable(nil)
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.3"
3
+ VERSION = "2.4.13"
4
4
  end
data/lib/graphql.rb CHANGED
@@ -5,8 +5,19 @@ 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
+ Schema.eager_load!
19
+ end
20
+
10
21
  class Error < StandardError
11
22
  end
12
23
 
@@ -74,53 +85,50 @@ This is probably a bug in GraphQL-Ruby, please report this error on GitHub: http
74
85
  end
75
86
 
76
87
  self.reject_numbers_followed_by_names = false
77
- end
78
88
 
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"
89
+ autoload :ExecutionError, "graphql/execution_error"
90
+ autoload :RuntimeTypeError, "graphql/runtime_type_error"
91
+ autoload :UnresolvedTypeError, "graphql/unresolved_type_error"
92
+ autoload :InvalidNullError, "graphql/invalid_null_error"
93
+ autoload :AnalysisError, "graphql/analysis_error"
94
+ autoload :CoercionError, "graphql/coercion_error"
95
+ autoload :InvalidNameError, "graphql/invalid_name_error"
96
+ autoload :IntegerDecodingError, "graphql/integer_decoding_error"
97
+ autoload :IntegerEncodingError, "graphql/integer_encoding_error"
98
+ autoload :StringEncodingError, "graphql/string_encoding_error"
99
+ autoload :DateEncodingError, "graphql/date_encoding_error"
100
+ autoload :DurationEncodingError, "graphql/duration_encoding_error"
101
+ autoload :TypeKinds, "graphql/type_kinds"
102
+ autoload :NameValidator, "graphql/name_validator"
103
+ autoload :Language, "graphql/language"
104
+
105
+ autoload :Analysis, "graphql/analysis"
106
+ autoload :Tracing, "graphql/tracing"
107
+ autoload :Dig, "graphql/dig"
108
+ autoload :Execution, "graphql/execution"
109
+ autoload :Pagination, "graphql/pagination"
110
+ autoload :Schema, "graphql/schema"
111
+ autoload :Query, "graphql/query"
112
+ autoload :Dataloader, "graphql/dataloader"
113
+ autoload :Types, "graphql/types"
114
+ autoload :StaticValidation, "graphql/static_validation"
115
+ autoload :Execution, "graphql/execution"
116
+ autoload :Introspection, "graphql/introspection"
117
+ autoload :Relay, "graphql/relay"
118
+ autoload :Subscriptions, "graphql/subscriptions"
119
+ autoload :ParseError, "graphql/parse_error"
120
+ autoload :Backtrace, "graphql/backtrace"
121
+
122
+ autoload :UnauthorizedError, "graphql/unauthorized_error"
123
+ autoload :UnauthorizedEnumValueError, "graphql/unauthorized_enum_value_error"
124
+ autoload :UnauthorizedFieldError, "graphql/unauthorized_field_error"
125
+ autoload :LoadApplicationObjectFailedError, "graphql/load_application_object_failed_error"
126
+ autoload :Testing, "graphql/testing"
127
+ autoload :Current, "graphql/current"
128
+ if defined?(::Rails::Engine)
129
+ autoload :Dashboard, 'graphql/dashboard'
130
+ end
131
+ end
115
132
 
116
133
  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"
134
+ require "graphql/railtie" if defined? Rails::Railtie