graphql-batch 0.4.3 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml DELETED
@@ -1,11 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.3
4
- - 2.7
5
- env:
6
- -
7
- GRAPHQL_VERSION: 1.9.19
8
- TESTING_LEGACY_DEFINITION_LAYER: true
9
- -
10
- GRAPHQL_VERSION: 1.10.2
11
- TESTING_LEGACY_DEFINITION_LAYER: false
@@ -1,45 +0,0 @@
1
- module GraphQL::Batch
2
- class Setup
3
- class << self
4
- def start_batching(executor_class)
5
- GraphQL::Batch::Executor.start_batch(executor_class)
6
- end
7
-
8
- def end_batching
9
- GraphQL::Batch::Executor.end_batch
10
- end
11
-
12
- def instrument_field(schema, type, field)
13
- return field unless type == schema.mutation
14
- old_resolve_proc = field.resolve_proc
15
- field.redefine do
16
- resolve ->(obj, args, ctx) {
17
- GraphQL::Batch::Executor.current.clear
18
- begin
19
- ::Promise.sync(old_resolve_proc.call(obj, args, ctx))
20
- ensure
21
- GraphQL::Batch::Executor.current.clear
22
- end
23
- }
24
- end
25
- end
26
- end
27
-
28
- def initialize(schema, executor_class:)
29
- @schema = schema
30
- @executor_class = executor_class
31
- end
32
-
33
- def before_query(query)
34
- Setup.start_batching(@executor_class)
35
- end
36
-
37
- def after_query(query)
38
- Setup.end_batching
39
- end
40
-
41
- def instrument(type, field)
42
- Setup.instrument_field(@schema, type, field)
43
- end
44
- end
45
- end