Sha256: 3b574b537f8d35bd1b984870261d12238640c25ce8df38c76dff81625cc7e985
Contents?: true
Size: 1.65 KB
Versions: 2
Compression:
Stored size: 1.65 KB
Contents
require "graphql" require "promise.rb" module GraphQL module Batch BrokenPromiseError = ::Promise::BrokenError class NoExecutorError < StandardError; end def self.batch(executor_class: GraphQL::Batch::Executor) begin GraphQL::Batch::Executor.start_batch(executor_class) ::Promise.sync(yield) ensure GraphQL::Batch::Executor.end_batch end end def self.use(schema_defn, executor_class: GraphQL::Batch::Executor) schema = schema_defn.target if GraphQL::VERSION >= "1.6.0" instrumentation = GraphQL::Batch::SetupMultiplex.new(schema, executor_class: executor_class) schema_defn.instrument(:multiplex, instrumentation) if schema.mutation if Gem::Version.new(GraphQL::VERSION) >= Gem::Version.new('1.9.0.pre3') && schema.mutation.metadata[:type_class] require_relative "batch/mutation_field_extension" schema.mutation.fields.each do |name, f| field = f.metadata[:type_class] field.extension(GraphQL::Batch::MutationFieldExtension) end else schema_defn.instrument(:field, instrumentation) end end else instrumentation = GraphQL::Batch::Setup.new(schema, executor_class: executor_class) schema_defn.instrument(:query, instrumentation) schema_defn.instrument(:field, instrumentation) end schema_defn.lazy_resolve(::Promise, :sync) end end end require_relative "batch/version" require_relative "batch/loader" require_relative "batch/executor" require_relative "batch/setup" require_relative "batch/setup_multiplex"
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
graphql-batch-0.4.1 | lib/graphql/batch.rb |
graphql-batch-edge-0.4.0 | lib/graphql/batch.rb |