graphql 2.2.10 → 2.2.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0ed6a9339a1c67dca4307a9753eeb5c25d8ff6cd32fa156de65e852ddb21f5e9
4
- data.tar.gz: 0ed35f51512eba4f60fa1c16d80d267f800c516d174c024d8beaa68fbcca3d33
3
+ metadata.gz: 4bcb377d757eba98e3b88e8a3af21bacbf00b7bb28ee994b7d517b5fb296c47a
4
+ data.tar.gz: 43a94034f284af6ecb62dd0961a67e706a7032000c7c500a8029a02995dd1881
5
5
  SHA512:
6
- metadata.gz: 159a9c932168794b7d4446ed0b207269c6f4ca05c45542c7632816a8bb0449b024f4879be95d8b762b0eb5e8969a31ce28915ec53853d4f67559d952908e59e2
7
- data.tar.gz: f153e397dd3b83504ca97ff44ac3f479228d7d18df5bf24879c8e8a8113e54d61ba26b8b9c74516bc05d47cb7febfcd507b12e6f3d42988b8dad9b5e3a7fa211
6
+ metadata.gz: bb67bbe99e21ce0f88632d6f5e965e842ff2714540d924721fb9234d9502b8ed596954c2748c406079052799386075f65d079c0e900df38c06f1cb1d422c61d8
7
+ data.tar.gz: 2e982944076364c91bc5dac75ff496762d973b0eed0c7b5913e27f5e01de0c0c2394047343c90e96f3f4d54db055adabf0268377bed6d6a06784b2f941b13ac7
@@ -81,6 +81,9 @@ module GraphQL
81
81
  end
82
82
  rescue Timeout::Error
83
83
  [GraphQL::AnalysisError.new("Timeout on validation of query")]
84
+ rescue GraphQL::UnauthorizedError
85
+ # This error was raised during analysis and will be returned the client before execution
86
+ []
84
87
  end
85
88
 
86
89
  def analysis_errors(results)
@@ -47,7 +47,7 @@ module GraphQL
47
47
  begin
48
48
  # Since this is basically the batching context,
49
49
  # share it for a whole multiplex
50
- multiplex.context[:interpreter_instance] ||= multiplex.schema.query_execution_strategy.new
50
+ multiplex.context[:interpreter_instance] ||= multiplex.schema.query_execution_strategy(deprecation_warning: false).new
51
51
  # Do as much eager evaluation of the query as possible
52
52
  results = []
53
53
  queries.each_with_index do |query, idx|
@@ -56,12 +56,12 @@ module GraphQL
56
56
  false
57
57
  end
58
58
 
59
- @has_next_page = if first_value && first
60
- # There are more items after these items
61
- sliced_nodes.count > first
62
- elsif before
59
+ @has_next_page = if before
63
60
  # The original array is longer than the `before` index
64
61
  index_from_cursor(before) < items.length + 1
62
+ elsif first
63
+ # There are more items after these items
64
+ sliced_nodes.count > first
65
65
  else
66
66
  false
67
67
  end
@@ -29,14 +29,14 @@ module GraphQL
29
29
 
30
30
  def has_next_page
31
31
  if @has_next_page.nil?
32
- @has_next_page = if first && first_value
32
+ @has_next_page = if before_offset && before_offset > 0
33
+ true
34
+ elsif first
33
35
  if @nodes && @nodes.count < first
34
36
  false
35
37
  else
36
38
  relation_larger_than(sliced_nodes, @sliced_nodes_offset, first)
37
39
  end
38
- elsif before_offset && before_offset > 0
39
- true
40
40
  else
41
41
  false
42
42
  end
@@ -471,6 +471,8 @@ module GraphQL
471
471
  if arguments[:last] && (max_possible_page_size.nil? || arguments[:last] > max_possible_page_size)
472
472
  max_possible_page_size = arguments[:last]
473
473
  end
474
+ elsif arguments.is_a?(GraphQL::UnauthorizedError)
475
+ raise arguments
474
476
  end
475
477
 
476
478
  if max_possible_page_size.nil?
@@ -50,7 +50,7 @@ module GraphQL
50
50
  if loads && arg_defn.type.list?
51
51
  class_eval <<-RUBY, __FILE__, __LINE__ + 1
52
52
  def #{method_owner}load_#{arg_defn.keyword}(values, context = nil)
53
- argument = get_argument("#{arg_defn.graphql_name}")
53
+ argument = get_argument("#{arg_defn.graphql_name}", context || self.context)
54
54
  (context || self.context).query.after_lazy(values) do |values2|
55
55
  GraphQL::Execution::Lazy.all(values2.map { |value| load_application_object(argument, value, context || self.context) })
56
56
  end
@@ -59,7 +59,7 @@ module GraphQL
59
59
  elsif loads
60
60
  class_eval <<-RUBY, __FILE__, __LINE__ + 1
61
61
  def #{method_owner}load_#{arg_defn.keyword}(value, context = nil)
62
- argument = get_argument("#{arg_defn.graphql_name}")
62
+ argument = get_argument("#{arg_defn.graphql_name}", context || self.context)
63
63
  load_application_object(argument, value, context || self.context)
64
64
  end
65
65
  RUBY
@@ -63,10 +63,6 @@ module GraphQL
63
63
  # Schemas can restrict large incoming queries with `max_depth` and `max_complexity` configurations.
64
64
  # (These configurations can be overridden by specific calls to {Schema#execute})
65
65
  #
66
- # Schemas can specify how queries should be executed against them.
67
- # `query_execution_strategy`, `mutation_execution_strategy` and `subscription_execution_strategy`
68
- # each apply to corresponding root types.
69
- #
70
66
  # @example defining a schema
71
67
  # class MySchema < GraphQL::Schema
72
68
  # query QueryType
@@ -167,13 +163,20 @@ module GraphQL
167
163
  backtrace_class.include(GraphQL::Backtrace::Trace)
168
164
  trace_mode(:default_backtrace, backtrace_class)
169
165
  end
170
- trace_class_for(:default)
166
+ trace_class_for(:default, build: true)
171
167
  end
172
168
 
173
169
  # @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))
170
+ def trace_class_for(mode, build: false)
171
+ if (trace_class = own_trace_modes[mode])
172
+ trace_class
173
+ elsif superclass.respond_to?(:trace_class_for) && (trace_class = superclass.trace_class_for(mode, build: false))
174
+ trace_class
175
+ elsif build
176
+ own_trace_modes[mode] = build_trace_mode(mode)
177
+ else
178
+ nil
179
+ end
177
180
  end
178
181
 
179
182
  # Configure `trace_class` to be used whenever `context: { trace_mode: mode_name }` is requested.
@@ -211,14 +214,14 @@ module GraphQL
211
214
  include DefaultTraceClass
212
215
  end
213
216
  when :default_backtrace
214
- schema_base_class = trace_class_for(:default)
217
+ schema_base_class = trace_class_for(:default, build: true)
215
218
  Class.new(schema_base_class) do
216
219
  include(GraphQL::Backtrace::Trace)
217
220
  end
218
221
  else
219
222
  # First, see if the superclass has a custom-defined class for this.
220
223
  # 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)
224
+ base_class = (superclass.respond_to?(:trace_class_for) && superclass.trace_class_for(mode)) || trace_class_for(:default, build: true)
222
225
  # Prepare the default trace class if it hasn't been initialized yet
223
226
  base_class ||= (own_trace_modes[:default] = build_trace_mode(:default))
224
227
  mods = trace_modules_for(mode)
@@ -644,27 +647,39 @@ module GraphQL
644
647
  end
645
648
  end
646
649
 
647
- def query_execution_strategy(new_query_execution_strategy = nil)
650
+ def query_execution_strategy(new_query_execution_strategy = nil, deprecation_warning: true)
651
+ if deprecation_warning
652
+ warn "GraphQL::Schema.query_execution_strategy is deprecated without replacement. Use `GraphQL::Query.new` directly to create and execute a custom query instead."
653
+ warn " #{caller(1, 1).first}"
654
+ end
648
655
  if new_query_execution_strategy
649
656
  @query_execution_strategy = new_query_execution_strategy
650
657
  else
651
- @query_execution_strategy || find_inherited_value(:query_execution_strategy, self.default_execution_strategy)
658
+ @query_execution_strategy || (superclass.respond_to?(:query_execution_strategy) ? superclass.query_execution_strategy(deprecation_warning: false) : self.default_execution_strategy)
652
659
  end
653
660
  end
654
661
 
655
- def mutation_execution_strategy(new_mutation_execution_strategy = nil)
662
+ def mutation_execution_strategy(new_mutation_execution_strategy = nil, deprecation_warning: true)
663
+ if deprecation_warning
664
+ warn "GraphQL::Schema.mutation_execution_strategy is deprecated without replacement. Use `GraphQL::Query.new` directly to create and execute a custom query instead."
665
+ warn " #{caller(1, 1).first}"
666
+ end
656
667
  if new_mutation_execution_strategy
657
668
  @mutation_execution_strategy = new_mutation_execution_strategy
658
669
  else
659
- @mutation_execution_strategy || find_inherited_value(:mutation_execution_strategy, self.default_execution_strategy)
670
+ @mutation_execution_strategy || (superclass.respond_to?(:mutation_execution_strategy) ? superclass.mutation_execution_strategy(deprecation_warning: false) : self.default_execution_strategy)
660
671
  end
661
672
  end
662
673
 
663
- def subscription_execution_strategy(new_subscription_execution_strategy = nil)
674
+ def subscription_execution_strategy(new_subscription_execution_strategy = nil, deprecation_warning: true)
675
+ if deprecation_warning
676
+ warn "GraphQL::Schema.subscription_execution_strategy is deprecated without replacement. Use `GraphQL::Query.new` directly to create and execute a custom query instead."
677
+ warn " #{caller(1, 1).first}"
678
+ end
664
679
  if new_subscription_execution_strategy
665
680
  @subscription_execution_strategy = new_subscription_execution_strategy
666
681
  else
667
- @subscription_execution_strategy || find_inherited_value(:subscription_execution_strategy, self.default_execution_strategy)
682
+ @subscription_execution_strategy || (superclass.respond_to?(:subscription_execution_strategy) ? superclass.subscription_execution_strategy(deprecation_warning: false) : self.default_execution_strategy)
668
683
  end
669
684
  end
670
685
 
@@ -1111,7 +1126,7 @@ module GraphQL
1111
1126
  end
1112
1127
 
1113
1128
  def tracer(new_tracer)
1114
- default_trace = trace_class_for(:default)
1129
+ default_trace = trace_class_for(:default, build: true)
1115
1130
  if default_trace.nil? || !(default_trace < GraphQL::Tracing::CallLegacyTracers)
1116
1131
  trace_with(GraphQL::Tracing::CallLegacyTracers)
1117
1132
  end
@@ -1163,10 +1178,14 @@ module GraphQL
1163
1178
  def trace_options_for(mode)
1164
1179
  @trace_options_for_mode ||= {}
1165
1180
  @trace_options_for_mode[mode] ||= begin
1181
+ # It may be time to create an options hash for a mode that wasn't registered yet.
1182
+ # Mix in the default options in that case.
1183
+ default_options = mode == :default ? EMPTY_HASH : trace_options_for(:default)
1184
+ # Make sure this returns a new object so that other hashes aren't modified later
1166
1185
  if superclass.respond_to?(:trace_options_for)
1167
- superclass.trace_options_for(mode).dup
1186
+ superclass.trace_options_for(mode).merge(default_options)
1168
1187
  else
1169
- {}
1188
+ default_options.dup
1170
1189
  end
1171
1190
  end
1172
1191
  end
@@ -1199,7 +1218,7 @@ module GraphQL
1199
1218
  options_trace_mode ||= trace_mode
1200
1219
  base_trace_options = trace_options_for(options_trace_mode)
1201
1220
  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}")
1221
+ trace_class_for_mode = trace_class_for(trace_mode, build: true)
1203
1222
  trace_class_for_mode.new(**trace_options)
1204
1223
  end
1205
1224
 
@@ -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.12"
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.12
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-03-06 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