graphql-batch 0.4.3 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +23 -0
- data/.rubocop.yml +7 -2
- data/.rubocop_todo.yml +7 -0
- data/Gemfile +4 -1
- data/README.md +9 -19
- data/Rakefile +9 -5
- data/examples/active_storage_loader.rb +75 -0
- data/examples/association_loader.rb +2 -1
- data/examples/http_loader.rb +1 -0
- data/examples/record_loader.rb +1 -0
- data/examples/window_key_loader.rb +81 -0
- data/graphql-batch.gemspec +2 -5
- data/lib/graphql/batch/loader.rb +24 -3
- data/lib/graphql/batch/setup_multiplex.rb +2 -6
- data/lib/graphql/batch/version.rb +1 -1
- data/lib/graphql/batch.rb +9 -22
- metadata +10 -10
- data/.rubocop-https---shopify-github-io-ruby-style-guide-rubocop-yml +0 -1029
- data/.travis.yml +0 -11
- data/lib/graphql/batch/setup.rb +0 -45
data/.travis.yml
DELETED
data/lib/graphql/batch/setup.rb
DELETED
@@ -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
|