Skip to content

Commit

Permalink
Update nonblocking dataloader tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rmosolgo committed Oct 24, 2024
1 parent abd7ee2 commit 71f6ebd
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions spec/graphql/dataloader/nonblocking_dataloader_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
require "spec_helper"

if Fiber.respond_to?(:scheduler) # Ruby 3+
describe GraphQL::Dataloader::NonblockingDataloader do
describe "GraphQL::Dataloader::NonblockingDataloader" do
class NonblockingSchema < GraphQL::Schema
class SleepSource < GraphQL::Dataloader::Source
def fetch(keys)
Expand Down Expand Up @@ -84,7 +84,7 @@ def wait_for(tag:, wait:)
end

query(Query)
use GraphQL::Dataloader::NonblockingDataloader
use GraphQL::Dataloader, nonblocking: true
end

def with_scheduler
Expand All @@ -99,7 +99,7 @@ def self.included(child_class)
child_class.class_eval do

it "runs IO in parallel by default" do
dataloader = GraphQL::Dataloader::NonblockingDataloader.new
dataloader = GraphQL::Dataloader.new(nonblocking: true)
results = {}
dataloader.append_job { sleep(0.1); results[:a] = 1 }
dataloader.append_job { sleep(0.2); results[:b] = 2 }
Expand All @@ -115,7 +115,7 @@ def self.included(child_class)
end

it "works with sources" do
dataloader = GraphQL::Dataloader::NonblockingDataloader.new
dataloader = GraphQL::Dataloader.new(nonblocking: true)
r1 = dataloader.with(NonblockingSchema::SleepSource).request(0.1)
r2 = dataloader.with(NonblockingSchema::SleepSource).request(0.2)
r3 = dataloader.with(NonblockingSchema::SleepSource).request(0.3)
Expand Down

0 comments on commit 71f6ebd

Please sign in to comment.