-
Notifications
You must be signed in to change notification settings - Fork 108
Expand file tree
/
Copy pathcustom_executor_test.rb
More file actions
43 lines (33 loc) · 943 Bytes
/
Copy pathcustom_executor_test.rb
File metadata and controls
43 lines (33 loc) · 943 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
require_relative 'test_helper'
class GraphQL::Batch::CustomExecutorTest < Minitest::Test
class MyCustomExecutor < GraphQL::Batch::Executor
class << self
attr_accessor :call_count
end
self.call_count = 0
def around_promise_callbacks
self.class.call_count += 1
super
end
end
class Schema < GraphQL::Schema
query ::QueryType
mutation ::MutationType
use GraphQL::Batch, executor_class: MyCustomExecutor
end
def setup
MyCustomExecutor.call_count = 0
end
def test_batch_accepts_custom_executor
product = GraphQL::Batch.batch(executor_class: MyCustomExecutor) do
RecordLoader.for(Product).load(1)
end
assert_equal 'Shirt', product.title
assert MyCustomExecutor.call_count > 0
end
def test_custom_executor_class
query_string = '{ product(id: "1") { id } }'
Schema.execute(query_string)
assert MyCustomExecutor.call_count > 0
end
end