graphql-batch 0.3.9 → 0.3.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -0
- data/lib/graphql/batch/loader.rb +4 -1
- data/lib/graphql/batch/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c793255ae48cf638179b9e786d03493a469d1629
|
4
|
+
data.tar.gz: d235b788e4f9208747d7145e7d2599c2279319d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7b263790b1871d54d9258e7bd2541c17361b8177a79e07aac146f9d3ccf05570cf07f8aaac40cf4dbe76c3b6f1677f3cd957a32904742c069a133d3906044767
|
7
|
+
data.tar.gz: d00d449a8872286251cc21d555b54be0690002f697dddb8afc1f43e6b90d75e42367ad70f54c701fc75d89b04427b4d127879481c406a24555d3ada35ce0582f
|
data/README.md
CHANGED
@@ -72,6 +72,12 @@ The loader class can be used from the resolve proc for a graphql field by callin
|
|
72
72
|
resolve -> (obj, args, context) { RecordLoader.for(Product).load(args["id"]) }
|
73
73
|
```
|
74
74
|
|
75
|
+
The loader also supports batch loading an array of records instead of just a single record, via `load_many`. For example:
|
76
|
+
|
77
|
+
```ruby
|
78
|
+
resolve -> (obj, args, context) { RecordLoader.for(Product).load_many(args["ids"]) }
|
79
|
+
```
|
80
|
+
|
75
81
|
Although this library doesn't have a dependency on active record,
|
76
82
|
the [examples directory](examples) has record and association loaders
|
77
83
|
for active record which handles edge cases like type casting ids
|
data/lib/graphql/batch/loader.rb
CHANGED
@@ -119,13 +119,16 @@ module GraphQL::Batch
|
|
119
119
|
|
120
120
|
def reject_pending_promises(load_keys, err)
|
121
121
|
load_keys.each do |key|
|
122
|
-
|
122
|
+
next unless promise_for(key).pending?
|
123
|
+
|
123
124
|
reject(key, err)
|
124
125
|
end
|
125
126
|
end
|
126
127
|
|
127
128
|
def check_for_broken_promises(load_keys)
|
128
129
|
load_keys.each do |key|
|
130
|
+
next unless promise_for(key).pending?
|
131
|
+
|
129
132
|
reject(key, ::Promise::BrokenError.new("#{self.class} didn't fulfill promise for key #{key.inspect}"))
|
130
133
|
end
|
131
134
|
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.
|
4
|
+
version: 0.3.10
|
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: 2018-
|
11
|
+
date: 2018-08-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: graphql
|