lib/graphql/batch.rb in graphql-batch-0.3.8 vs lib/graphql/batch.rb in graphql-batch-0.3.9
- old
+ new
@@ -5,18 +5,17 @@
require "promise.rb"
module GraphQL
module Batch
BrokenPromiseError = ::Promise::BrokenError
- class NestedError < StandardError; end
+ class NoExecutorError < StandardError; end
- def self.batch
- raise NestedError if GraphQL::Batch::Executor.current
+ def self.batch(executor_class: GraphQL::Batch::Executor)
begin
- GraphQL::Batch::Executor.current = GraphQL::Batch::Executor.new
+ GraphQL::Batch::Executor.start_batch(executor_class)
::Promise.sync(yield)
ensure
- GraphQL::Batch::Executor.current = nil
+ GraphQL::Batch::Executor.end_batch
end
end
def self.use(schema_defn, executor_class: GraphQL::Batch::Executor)
schema = schema_defn.target