Skip to content

Commit 550eb84

Browse files
committed
Use top-level Sync instead of plain Fiber for AsyncDataloader
1 parent 156f6f3 commit 550eb84

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

lib/graphql/analysis/query_complexity.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ def result
2727
future_complexity
2828
end
2929
when nil
30-
subject.logger.warn <<~GRAPHQL
30+
subject.logger.warn <<~MESSAGE
3131
GraphQL-Ruby's complexity cost system is getting some "breaking fixes" in a future version. See the migration notes at https://graphql-ruby.org/api-doc/#{GraphQL::VERSION}/GraphQL/Schema.html#complexity_cost_calculation_mode_for-class_method
3232
3333
To opt into the future behavior, configure your schema (#{subject.schema.name ? subject.schema.name : subject.schema.ancestors}) with:
3434
3535
complexity_cost_calculation_mode(:future) # or `:legacy`, `:compare`
3636
37-
GRAPHQL
37+
MESSAGE
3838
max_possible_complexity(mode: :legacy)
3939
else
4040
raise ArgumentError, "Expected `:future`, `:legacy`, `:compare`, or `nil` from `#{query.schema}.complexity_cost_calculation_mode_for` but got: #{query.schema.complexity_cost_calculation_mode.inspect}"

lib/graphql/dataloader/async_dataloader.rb

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ def run(trace_query_lazy: nil)
2323
next_source_tasks = []
2424
first_pass = true
2525
sources_condition = Async::Condition.new
26-
manager = spawn_fiber do
26+
fiber_vars = get_fiber_variables
27+
Sync do
28+
set_fiber_variables(fiber_vars)
2729
trace&.begin_dataloader(self)
2830
while first_pass || !job_fibers.empty?
2931
first_pass = false
@@ -55,12 +57,6 @@ def run(trace_query_lazy: nil)
5557
end
5658
trace&.end_dataloader(self)
5759
end
58-
59-
manager.resume
60-
if manager.alive?
61-
raise "Invariant: Manager didn't terminate successfully: #{manager}"
62-
end
63-
6460
rescue UncaughtThrowError => e
6561
throw e.tag, e.value
6662
end

0 commit comments

Comments
 (0)