lib/graphql/batch.rb in graphql-batch-0.2.5 vs lib/graphql/batch.rb in graphql-batch-0.3.0

- old
+ new

@@ -1,15 +1,31 @@ require "graphql" require "promise.rb" module GraphQL module Batch - BrokenPromiseError = Class.new(StandardError) + BrokenPromiseError = ::Promise::BrokenError + class NestedError < StandardError; end + + def self.batch + raise NestedError if GraphQL::Batch::Executor.current + begin + GraphQL::Batch::Executor.current = GraphQL::Batch::Executor.new + Promise.sync(yield) + ensure + GraphQL::Batch::Executor.current = nil + end + end end end require_relative "batch/version" require_relative "batch/loader" require_relative "batch/executor" require_relative "batch/promise" -require_relative "batch/execution_strategy" -require_relative "batch/mutation_execution_strategy" +require_relative "batch/setup" + +# Allow custom execution strategies to be removed upstream +if defined?(GraphQL::Query::SerialExecution) + require_relative "batch/execution_strategy" + require_relative "batch/mutation_execution_strategy" +end