graphql 2.2.10 → 2.2.11

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.

Potentially problematic release.


This version of graphql might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0ed6a9339a1c67dca4307a9753eeb5c25d8ff6cd32fa156de65e852ddb21f5e9
4
- data.tar.gz: 0ed35f51512eba4f60fa1c16d80d267f800c516d174c024d8beaa68fbcca3d33
3
+ metadata.gz: 1bae060f1dcf449082e9e53be024476505d848448a13d592f31e67c11024caa4
4
+ data.tar.gz: ebc753b89b657c18771641869a4dffea9e79fe324a3f7e46c1a84304a6cc3375
5
5
  SHA512:
6
- metadata.gz: 159a9c932168794b7d4446ed0b207269c6f4ca05c45542c7632816a8bb0449b024f4879be95d8b762b0eb5e8969a31ce28915ec53853d4f67559d952908e59e2
7
- data.tar.gz: f153e397dd3b83504ca97ff44ac3f479228d7d18df5bf24879c8e8a8113e54d61ba26b8b9c74516bc05d47cb7febfcd507b12e6f3d42988b8dad9b5e3a7fa211
6
+ metadata.gz: 0bd27d12cd1efd1c4166c20062e401fa524bcda469de51cbfe89fd21542fd3433a2f23628c21330c9e3d700a9627c683a6a1691887a06ef06105ede4c2241b26
7
+ data.tar.gz: abc65a9217ae76239458695a3ee47d3e2bf3d072e16d62b9df16a65a380110e4a9a207af17473ca0f14fcce5d907a2552866597dd53785c890979a37aa2c500b
@@ -167,13 +167,20 @@ module GraphQL
167
167
  backtrace_class.include(GraphQL::Backtrace::Trace)
168
168
  trace_mode(:default_backtrace, backtrace_class)
169
169
  end
170
- trace_class_for(:default)
170
+ trace_class_for(:default, build: true)
171
171
  end
172
172
 
173
173
  # @return [Class] Return the trace class to use for this mode, looking one up on the superclass if this Schema doesn't have one defined.
174
- def trace_class_for(mode, build: true)
175
- own_trace_modes[mode] ||
176
- (superclass.respond_to?(:trace_class_for) ? superclass.trace_class_for(mode, build: build) : (build ? (own_trace_modes[mode] = build_trace_mode(mode)) : nil))
174
+ def trace_class_for(mode, build: false)
175
+ if (trace_class = own_trace_modes[mode])
176
+ trace_class
177
+ elsif superclass.respond_to?(:trace_class_for) && (trace_class = superclass.trace_class_for(mode, build: false))
178
+ trace_class
179
+ elsif build
180
+ own_trace_modes[mode] = build_trace_mode(mode)
181
+ else
182
+ nil
183
+ end
177
184
  end
178
185
 
179
186
  # Configure `trace_class` to be used whenever `context: { trace_mode: mode_name }` is requested.
@@ -211,14 +218,14 @@ module GraphQL
211
218
  include DefaultTraceClass
212
219
  end
213
220
  when :default_backtrace
214
- schema_base_class = trace_class_for(:default)
221
+ schema_base_class = trace_class_for(:default, build: true)
215
222
  Class.new(schema_base_class) do
216
223
  include(GraphQL::Backtrace::Trace)
217
224
  end
218
225
  else
219
226
  # First, see if the superclass has a custom-defined class for this.
220
227
  # Then, if it doesn't, use this class's default trace
221
- base_class = (superclass.respond_to?(:trace_class_for) && superclass.trace_class_for(mode, build: false)) || trace_class_for(:default)
228
+ base_class = (superclass.respond_to?(:trace_class_for) && superclass.trace_class_for(mode)) || trace_class_for(:default, build: true)
222
229
  # Prepare the default trace class if it hasn't been initialized yet
223
230
  base_class ||= (own_trace_modes[:default] = build_trace_mode(:default))
224
231
  mods = trace_modules_for(mode)
@@ -1111,7 +1118,7 @@ module GraphQL
1111
1118
  end
1112
1119
 
1113
1120
  def tracer(new_tracer)
1114
- default_trace = trace_class_for(:default)
1121
+ default_trace = trace_class_for(:default, build: true)
1115
1122
  if default_trace.nil? || !(default_trace < GraphQL::Tracing::CallLegacyTracers)
1116
1123
  trace_with(GraphQL::Tracing::CallLegacyTracers)
1117
1124
  end
@@ -1163,10 +1170,14 @@ module GraphQL
1163
1170
  def trace_options_for(mode)
1164
1171
  @trace_options_for_mode ||= {}
1165
1172
  @trace_options_for_mode[mode] ||= begin
1173
+ # It may be time to create an options hash for a mode that wasn't registered yet.
1174
+ # Mix in the default options in that case.
1175
+ default_options = mode == :default ? EMPTY_HASH : trace_options_for(:default)
1176
+ # Make sure this returns a new object so that other hashes aren't modified later
1166
1177
  if superclass.respond_to?(:trace_options_for)
1167
- superclass.trace_options_for(mode).dup
1178
+ superclass.trace_options_for(mode).merge(default_options)
1168
1179
  else
1169
- {}
1180
+ default_options.dup
1170
1181
  end
1171
1182
  end
1172
1183
  end
@@ -1199,7 +1210,7 @@ module GraphQL
1199
1210
  options_trace_mode ||= trace_mode
1200
1211
  base_trace_options = trace_options_for(options_trace_mode)
1201
1212
  trace_options = base_trace_options.merge(options)
1202
- trace_class_for_mode = trace_class_for(trace_mode) || raise(ArgumentError, "#{self} has no trace class for mode: #{trace_mode.inspect}")
1213
+ trace_class_for_mode = trace_class_for(trace_mode, build: true)
1203
1214
  trace_class_for_mode.new(**trace_options)
1204
1215
  end
1205
1216
 
@@ -5,6 +5,24 @@ module GraphQL
5
5
  module SentryTrace
6
6
  include PlatformTrace
7
7
 
8
+ # @param set_transaction_name [Boolean] If true, the GraphQL operation name will be used as the transaction name.
9
+ # This is not advised if you run more than one query per HTTP request, for example, with `graphql-client` or multiplexing.
10
+ # It can also be specified per-query with `context[:set_sentry_transaction_name]`.
11
+ def initialize(set_transaction_name: false, **_rest)
12
+ @set_transaction_name = set_transaction_name
13
+ super
14
+ end
15
+
16
+ def execute_query(**data)
17
+ set_this_txn_name = data[:query].context[:set_sentry_transaction_name]
18
+ if set_this_txn_name == true || (set_this_txn_name.nil? && @set_transaction_name)
19
+ Sentry.configure_scope do |scope|
20
+ scope.set_transaction_name(transaction_name(data[:query]))
21
+ end
22
+ end
23
+ instrument_execution("graphql.execute", "execute_query", data) { super }
24
+ end
25
+
8
26
  {
9
27
  "lex" => "graphql.lex",
10
28
  "parse" => "graphql.parse",
@@ -12,7 +30,6 @@ module GraphQL
12
30
  "analyze_query" => "graphql.analyze",
13
31
  "analyze_multiplex" => "graphql.analyze_multiplex",
14
32
  "execute_multiplex" => "graphql.execute_multiplex",
15
- "execute_query" => "graphql.execute",
16
33
  "execute_query_lazy" => "graphql.execute"
17
34
  }.each do |trace_method, platform_key|
18
35
  module_eval <<-RUBY, __FILE__, __LINE__
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module GraphQL
3
- VERSION = "2.2.10"
3
+ VERSION = "2.2.11"
4
4
  end
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.2.10
4
+ version: 2.2.11
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-02-20 00:00:00.000000000 Z
11
+ date: 2024-02-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: base64
@@ -631,7 +631,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
631
631
  - !ruby/object:Gem::Version
632
632
  version: '0'
633
633
  requirements: []
634
- rubygems_version: 3.5.5
634
+ rubygems_version: 3.5.3
635
635
  signing_key:
636
636
  specification_version: 4
637
637
  summary: A GraphQL language and runtime for Ruby