class GraphQL::Batch::Setup
Public Class Methods
after_query(query)
click to toggle source
# File lib/graphql/batch/setup.rb, line 32 def after_query(query) end_batching end
before_query(query)
click to toggle source
# File lib/graphql/batch/setup.rb, line 27 def before_query(query) warn "Deprecated graphql-batch setup `instrument(:query, GraphQL::Batch::Setup)`, replace with `use GraphQL::Batch`" start_batching(GraphQL::Batch::Executor) end
end_batching()
click to toggle source
# File lib/graphql/batch/setup.rb, line 8 def end_batching GraphQL::Batch::Executor.end_batch end
instrument_field(schema, type, field)
click to toggle source
# File lib/graphql/batch/setup.rb, line 12 def instrument_field(schema, type, field) return field unless type == schema.mutation old_resolve_proc = field.resolve_proc field.redefine do resolve ->(obj, args, ctx) { GraphQL::Batch::Executor.current.clear begin ::Promise.sync(old_resolve_proc.call(obj, args, ctx)) ensure GraphQL::Batch::Executor.current.clear end } end end
new(schema, executor_class:)
click to toggle source
# File lib/graphql/batch/setup.rb, line 37 def initialize(schema, executor_class:) @schema = schema @executor_class = executor_class end
start_batching(executor_class)
click to toggle source
# File lib/graphql/batch/setup.rb, line 4 def start_batching(executor_class) GraphQL::Batch::Executor.start_batch(executor_class) end
Public Instance Methods
after_query(query)
click to toggle source
# File lib/graphql/batch/setup.rb, line 46 def after_query(query) Setup.end_batching end
before_query(query)
click to toggle source
# File lib/graphql/batch/setup.rb, line 42 def before_query(query) Setup.start_batching(@executor_class) end
instrument(type, field)
click to toggle source
# File lib/graphql/batch/setup.rb, line 50 def instrument(type, field) Setup.instrument_field(@schema, type, field) end