graphql-batch 0.3.1 → 0.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3ae7754876a6ce37072721f5f69e56af29de783a
4
- data.tar.gz: 0cc9fa2b9f612543adb13a889b5d7d9e3756e5fa
3
+ metadata.gz: 0a7998f99327121197626be0735b7af3a016ca5a
4
+ data.tar.gz: f4a64bc74b428f31cc331bf8c9c7399df048a341
5
5
  SHA512:
6
- metadata.gz: 007f8c44eabe9c5edcb2d1bb58fc4fa2e725a728cd5c2a3f41a9ffebdf36aba8cdac639f1e356aa6f0bde33a6d03f0a4f9ce697cf491badf21b9470b210d1fd6
7
- data.tar.gz: 1353b91cdbfe336630cb34b7ead64dd366df643f3275c2d800129ffc049c7d1183532f5e3c4355cfad73b52063c6cc927481225d2fb022b043c71f8b9b5013f8
6
+ metadata.gz: be04e6e7d48f326f2e5fdfdad8b9c3e42401f2a84e43a5bb420aa329bdf2fe5f0b25a478c2a53c3356858d49522a65d8c8a7aa7386146600fe687fc5d48001bc
7
+ data.tar.gz: 123332a5424e352958781e69767cc818f9ef66c0b06397ab88ceff309bd58c93775225b99f15e806ca5e1575019dc5ac4ff56c5dfa6b81615a5ade1580047681
data/README.md CHANGED
@@ -46,14 +46,23 @@ class RecordLoader < GraphQL::Batch::Loader
46
46
  end
47
47
  ```
48
48
 
49
- Use lazy execution and instrumentation by `GraphQL::Batch` in your schema
49
+ Use `GraphQL::Batch` as a plugin in your schema (for graphql >= `1.5.0`).
50
50
 
51
51
  ```ruby
52
52
  MySchema = GraphQL::Schema.define do
53
53
  query MyQueryType
54
54
 
55
- lazy_resolve(Promise, :sync)
56
- instrument(:query, GraphQL::Batch::Setup)
55
+ use GraphQL::Batch
56
+ end
57
+ ```
58
+
59
+ For pre `1.5.0` versions:
60
+
61
+ ```ruby
62
+ MySchema = GraphQL::Schema.define do
63
+ query MyQueryType
64
+
65
+ GraphQL::Batch.use(self)
57
66
  end
58
67
  ```
59
68
 
data/lib/graphql/batch.rb CHANGED
@@ -19,6 +19,11 @@ module GraphQL
19
19
  end
20
20
  end
21
21
 
22
+ def self.use(schema_defn)
23
+ schema_defn.instrument(:query, GraphQL::Batch::Setup)
24
+ schema_defn.lazy_resolve(::Promise, :sync)
25
+ end
26
+
22
27
  autoload :ExecutionStrategy, 'graphql/batch/execution_strategy'
23
28
  autoload :MutationExecutionStrategy, 'graphql/batch/mutation_execution_strategy'
24
29
  end
@@ -1,4 +1,4 @@
1
- warn "GraphQL::Batch::ExecutionStrategy is deprecated, instead use `lazy_resolve(Promise, :sync)` and `instrument(:query, GraphQL::Batch::Setup)` in GraphQL::Schema.define"
1
+ warn "GraphQL::Batch::ExecutionStrategy is deprecated, instead add `use GraphQL::Batch` in GraphQL::Schema.define"
2
2
 
3
3
  module GraphQL::Batch
4
4
  class ExecutionStrategy < GraphQL::Query::SerialExecution
@@ -1,8 +1,17 @@
1
1
  module GraphQL::Batch
2
2
  class Loader
3
+ class NoExecutorError < StandardError; end
4
+
3
5
  def self.for(*group_args)
4
6
  loader_key = [self].concat(group_args)
5
7
  executor = Executor.current
8
+
9
+ unless executor
10
+ raise NoExecutorError, "Cannot create loader without an Executor."\
11
+ " Wrap the call to `for` with `GraphQL::Batch.batch` or use"\
12
+ " `GraphQL::Batch::Setup` as a query instrumenter if using with `graphql-ruby`"
13
+ end
14
+
6
15
  executor.loaders[loader_key] ||= new(*group_args).tap do |loader|
7
16
  loader.loader_key = loader_key
8
17
  loader.executor = executor
@@ -1,5 +1,5 @@
1
1
  module GraphQL
2
2
  module Batch
3
- VERSION = "0.3.1"
3
+ VERSION = "0.3.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphql-batch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dylan Thacker-Smith
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-01-11 00:00:00.000000000 Z
11
+ date: 2017-04-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: graphql
@@ -145,7 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
145
145
  version: '0'
146
146
  requirements: []
147
147
  rubyforge_project:
148
- rubygems_version: 2.5.1
148
+ rubygems_version: 2.5.2
149
149
  signing_key:
150
150
  specification_version: 4
151
151
  summary: A query batching executor for the graphql gem