graphql 2.1.9 → 2.1.10

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: 85210767fa6162b49189f17ff57be701393a99cc19b78750b6a47004a66d7310
4
- data.tar.gz: 4ae9769770245ed92151e4779698ef280c1f22b4d39167c41a5d1ecd337da771
3
+ metadata.gz: aa975ca1c39b6de261e95d5b4e44f4d65cf3a52d5abeca978a03cb617732c709
4
+ data.tar.gz: ca123726f134ec05b94176591c0770eb46c4bc2b85202ab90905c2394d3269a5
5
5
  SHA512:
6
- metadata.gz: 1352340c9daf585df4eac26079530aa1b53f2fca54286505d2884620e0c245178ec2d28435764cf90ec9fb9f2beb4865c7e3a2a457e1db6b74949c600a951bcf
7
- data.tar.gz: 2f4145975d6c8e61db4a48a92f0bc676a953c59b180ec2fc9f0b4c7a572ae4b4ac214cc6edbc95e2bfa953a0e2bf29bb73da770efcafabe696b4df2fbbb0f4fc
6
+ metadata.gz: 18c0b1dbdee834116c64174db429d25176a84dd6cc076c64969995e00b6caa9e8c1fae1f5cdf27b703091515829ac5c2743db3088bb6b290fb1c294ba56c82fb
7
+ data.tar.gz: b10c8bdb7fb16fbe289542e08237d281bd57a40885aa7176c261f564c32a1250ffe2e94ef767502079f91938c51db059c382fc2ae4c1badebcc9a90746fd85ff
@@ -168,7 +168,7 @@ module GraphQL
168
168
  nil
169
169
  end
170
170
 
171
- attr_reader :pending
171
+ attr_reader :pending, :results
172
172
 
173
173
  private
174
174
 
@@ -118,12 +118,7 @@ module GraphQL
118
118
  #
119
119
  # @return [void]
120
120
  def yield
121
- if use_fiber_resume?
122
- Fiber.yield
123
- else
124
- parent_fiber = Thread.current[:parent_fiber]
125
- parent_fiber.transfer
126
- end
121
+ Fiber.yield
127
122
  nil
128
123
  end
129
124
 
@@ -168,7 +163,11 @@ module GraphQL
168
163
  ensure
169
164
  @pending_jobs = prev_queue
170
165
  prev_pending_keys.each do |source_instance, pending|
171
- source_instance.pending.merge!(pending)
166
+ pending.each do |key, value|
167
+ if !source_instance.results.key?(key)
168
+ source_instance.pending[key] = value
169
+ end
170
+ end
172
171
  end
173
172
  end
174
173
 
@@ -178,62 +177,62 @@ module GraphQL
178
177
  source_fibers = []
179
178
  next_source_fibers = []
180
179
  first_pass = true
180
+ manager = spawn_fiber do
181
+ while first_pass || job_fibers.any?
182
+ first_pass = false
181
183
 
182
- while first_pass || job_fibers.any?
183
- first_pass = false
184
-
185
- while (f = job_fibers.shift || spawn_job_fiber)
186
- if f.alive?
187
- run_fiber(f)
188
- next_job_fibers << f
184
+ while (f = (job_fibers.shift || spawn_job_fiber))
185
+ if f.alive?
186
+ finished = run_fiber(f)
187
+ if !finished
188
+ next_job_fibers << f
189
+ end
190
+ end
189
191
  end
190
- end
191
- join_queues(job_fibers, next_job_fibers)
192
+ join_queues(job_fibers, next_job_fibers)
192
193
 
193
- while source_fibers.any? || @source_cache.each_value.any? { |group_sources| group_sources.each_value.any?(&:pending?) }
194
- while (f = source_fibers.shift || spawn_source_fiber)
195
- if f.alive?
196
- run_fiber(f)
197
- next_source_fibers << f
194
+ while source_fibers.any? || @source_cache.each_value.any? { |group_sources| group_sources.each_value.any?(&:pending?) }
195
+ while (f = source_fibers.shift || spawn_source_fiber)
196
+ if f.alive?
197
+ finished = run_fiber(f)
198
+ if !finished
199
+ next_source_fibers << f
200
+ end
201
+ end
198
202
  end
203
+ join_queues(source_fibers, next_source_fibers)
199
204
  end
200
- join_queues(source_fibers, next_source_fibers)
201
205
  end
202
206
  end
203
207
 
208
+ run_fiber(manager)
209
+
210
+ if manager.alive?
211
+ raise "Invariant: Manager fiber didn't terminate properly."
212
+ end
213
+
204
214
  if job_fibers.any?
205
215
  raise "Invariant: job fibers should have exited but #{job_fibers.size} remained"
206
216
  end
207
217
  if source_fibers.any?
208
218
  raise "Invariant: source fibers should have exited but #{source_fibers.size} remained"
209
219
  end
210
-
211
220
  rescue UncaughtThrowError => e
212
221
  throw e.tag, e.value
213
222
  end
214
223
 
215
224
  def run_fiber(f)
216
- if use_fiber_resume?
217
- f.resume
218
- else
219
- f.transfer
220
- end
225
+ f.resume
221
226
  end
222
227
 
223
228
  def spawn_fiber
224
229
  fiber_vars = get_fiber_variables
225
- parent_fiber = use_fiber_resume? ? nil : Fiber.current
226
230
  Fiber.new(blocking: !@nonblocking) {
227
231
  set_fiber_variables(fiber_vars)
228
- Thread.current[:parent_fiber] = parent_fiber
229
232
  yield
230
233
  # With `.transfer`, you have to explicitly pass back to the parent --
231
234
  # if the fiber is allowed to terminate normally, control is passed to the main fiber instead.
232
- if parent_fiber
233
- parent_fiber.transfer(true)
234
- else
235
- true
236
- end
235
+ true
237
236
  }
238
237
  end
239
238
 
@@ -245,15 +244,6 @@ module GraphQL
245
244
  new_queue.clear
246
245
  end
247
246
 
248
- def use_fiber_resume?
249
- Fiber.respond_to?(:scheduler) &&
250
- (
251
- (defined?(::DummyScheduler) && Fiber.scheduler.is_a?(::DummyScheduler)) ||
252
- (defined?(::Evt) && ::Evt::Scheduler.singleton_class::BACKENDS.any? { |be| Fiber.scheduler.is_a?(be) }) ||
253
- (defined?(::Libev) && Fiber.scheduler.is_a?(::Libev::Scheduler))
254
- )
255
- end
256
-
257
247
  def spawn_job_fiber
258
248
  if @pending_jobs.any?
259
249
  spawn_fiber do
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module GraphQL
3
- VERSION = "2.1.9"
3
+ VERSION = "2.1.10"
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.1.9
4
+ version: 2.1.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Mosolgo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-12-21 00:00:00.000000000 Z
11
+ date: 2023-12-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: racc