graphql 2.2.3 → 2.2.4

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: 7177c15aedde0b99419bee77e944a4907bb84e39b5e9aafb05b2a1360903f3e6
4
- data.tar.gz: e7252b975a41c1d8a0871e71a3fc37522741c0b872899f2f33863b76ad09934d
3
+ metadata.gz: 87199d36a0f9e158d8892e0e9ca2086f89c321adbbe5dec68b16e662ccb5e912
4
+ data.tar.gz: 5dde06249941e5ce75bc06613c37bf75cc8d6c110a1e7c39f1fede566bb0d160
5
5
  SHA512:
6
- metadata.gz: d29b25a1186ce62664cd2225de1eac675925ebbf93ed14c6513a1008c7cd6a1b01b375a1785082ab14024ead927a073f8e3afb72ffa5905a342fcdec6a60d9fa
7
- data.tar.gz: 6d2a445f577027d5f87a0a0ee0f0c1a562d494d7d9a5bc7209dfbb2fc5c98ce38f5fab86e7101b6537f9b9b590a2d41e1303f5dc606809683a1bde22c6bc283d
6
+ metadata.gz: a2da271a3986e6859048054a64021fdb900b71439abec89b3f0b89ef5b2607266c507dae5e3de81b305028c7ba45cde8e7271612fabeda45ac9e8a18be3d9818
7
+ data.tar.gz: 80a579e0e22967804de66b86fa98a5c0041d45ca1665beba4e50ef5045848364da5b71d115cbe862d308b72919723b121b8a001c9185b664c2394dcc054d5f20
@@ -3,69 +3,63 @@ module GraphQL
3
3
  class Dataloader
4
4
  class AsyncDataloader < Dataloader
5
5
  def yield
6
- Thread.current[:graphql_dataloader_next_tick].wait
6
+ if (condition = Thread.current[:graphql_dataloader_next_tick])
7
+ condition.wait
8
+ else
9
+ Fiber.yield
10
+ end
7
11
  nil
8
12
  end
9
13
 
10
14
  def run
11
- job_tasks = []
12
- next_job_tasks = []
15
+ job_fibers = []
16
+ next_job_fibers = []
13
17
  source_tasks = []
14
18
  next_source_tasks = []
15
19
  first_pass = true
16
- jobs_condition = Async::Condition.new
17
20
  sources_condition = Async::Condition.new
18
- Sync do |root_task|
19
- while first_pass || job_tasks.any?
21
+ manager = spawn_fiber do
22
+ while first_pass || job_fibers.any?
20
23
  first_pass = false
21
24
 
22
- while (task = job_tasks.shift || spawn_job_task(root_task, jobs_condition))
23
- if task.alive?
24
- next_job_tasks << task
25
- elsif task.failed?
26
- # re-raise a raised error -
27
- # this also covers errors from sources since
28
- # these jobs wait for sources as needed.
29
- task.wait
25
+ while (f = (job_fibers.shift || spawn_job_fiber))
26
+ if f.alive?
27
+ finished = run_fiber(f)
28
+ if !finished
29
+ next_job_fibers << f
30
+ end
30
31
  end
31
32
  end
32
- root_task.yield # give job tasks a chance to run
33
- job_tasks.concat(next_job_tasks)
34
- next_job_tasks.clear
33
+ job_fibers.concat(next_job_fibers)
34
+ next_job_fibers.clear
35
35
 
36
- while source_tasks.any? || @source_cache.each_value.any? { |group_sources| group_sources.each_value.any?(&:pending?) }
37
- while (task = source_tasks.shift || spawn_source_task(root_task, sources_condition))
38
- if task.alive?
39
- next_source_tasks << task
36
+ Sync do |root_task|
37
+ while source_tasks.any? || @source_cache.each_value.any? { |group_sources| group_sources.each_value.any?(&:pending?) }
38
+ while (task = source_tasks.shift || spawn_source_task(root_task, sources_condition))
39
+ if task.alive?
40
+ root_task.yield # give the source task a chance to run
41
+ next_source_tasks << task
42
+ end
40
43
  end
44
+ sources_condition.signal
45
+ source_tasks.concat(next_source_tasks)
46
+ next_source_tasks.clear
41
47
  end
42
- root_task.yield # give source tasks a chance to run
43
- sources_condition.signal
44
- source_tasks.concat(next_source_tasks)
45
- next_source_tasks.clear
46
48
  end
47
- jobs_condition.signal
48
49
  end
49
50
  end
51
+
52
+ manager.resume
53
+ if manager.alive?
54
+ raise "Invariant: Manager didn't terminate successfully: #{manager}"
55
+ end
56
+
50
57
  rescue UncaughtThrowError => e
51
58
  throw e.tag, e.value
52
59
  end
53
60
 
54
61
  private
55
62
 
56
- def spawn_job_task(parent_task, condition)
57
- if @pending_jobs.any?
58
- fiber_vars = get_fiber_variables
59
- parent_task.async do
60
- set_fiber_variables(fiber_vars)
61
- Thread.current[:graphql_dataloader_next_tick] = condition
62
- while job = @pending_jobs.shift
63
- job.call
64
- end
65
- end
66
- end
67
- end
68
-
69
63
  def spawn_source_task(parent_task, condition)
70
64
  pending_sources = nil
71
65
  @source_cache.each_value do |source_by_batch_params|
@@ -513,7 +513,7 @@ module GraphQL
513
513
  end
514
514
  when Array
515
515
  # It's an array full of execution errors; add them all.
516
- if value.any? && value.all? { |v| v.is_a?(GraphQL::ExecutionError) }
516
+ if value.any? && value.all?(GraphQL::ExecutionError)
517
517
  list_type_at_all = (field && (field.type.list?))
518
518
  if selection_result.nil? || !dead_result?(selection_result)
519
519
  value.each_with_index do |error, index|
@@ -566,6 +566,15 @@ module GraphQL
566
566
  when :NULL
567
567
  advance_token
568
568
  "null"
569
+ when :ON
570
+ advance_token
571
+ "on"
572
+ when :DIRECTIVE
573
+ advance_token
574
+ "directive"
575
+ when :EXTEND
576
+ advance_token
577
+ "extend"
569
578
  else
570
579
  expect_token(:NAME)
571
580
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module GraphQL
3
- VERSION = "2.2.3"
3
+ VERSION = "2.2.4"
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.3
4
+ version: 2.2.4
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-28 00:00:00.000000000 Z
11
+ date: 2024-01-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: racc