graphql-preload 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/lib/graphql/preload/instrument.rb +1 -0
- data/lib/graphql/preload/loader.rb +2 -1
- data/lib/graphql/preload/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: b779bc0472181687609ba597178bd337c1653dfc
|
4
|
+
data.tar.gz: cdb4a938912f4337650e9f9f710083f8f2fe33f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 21b41bf9c3c001560f37598d0040a2651812fd298cd692108dacb35750992cab9d5172ae7f84164225c5621ffdd1c50d5e06a5ad192e1c295ce723747581d663
|
7
|
+
data.tar.gz: d9f543bf8f0a4d30024da23e4baf620c546fcd3db253b9076b98da793c8a232b4281c473805d608c6b152c115cec2e1f740fda54594812d56ada7316ef27d759
|
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# GraphQL::Preload
|
2
2
|
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/graphql-preload.svg)](https://rubygems.org/gems/graphql-preload)
|
4
|
+
|
3
5
|
Provides a DSL for the [`graphql` gem](https://github.com/rmosolgo/graphql-ruby) that allows ActiveRecord associations to be preloaded in field definitions. Based on a [gist](https://gist.github.com/theorygeek/a1a59a2bf9c59e4b3706ac68d12c8434) by @theorygeek.
|
4
6
|
|
5
7
|
## Installation
|
@@ -20,6 +20,7 @@ module GraphQL
|
|
20
20
|
end
|
21
21
|
|
22
22
|
private def preload(record, associations)
|
23
|
+
raise TypeError, "Expected #{associations} to be a Symbol, not a String" if associations.is_a?(String)
|
23
24
|
return preload_single_association(record, associations) if associations.is_a?(Symbol)
|
24
25
|
|
25
26
|
promises = []
|
@@ -34,7 +34,8 @@ module GraphQL
|
|
34
34
|
end
|
35
35
|
|
36
36
|
private def preload_association(records)
|
37
|
-
if ActiveRecord::VERSION::MAJOR
|
37
|
+
if ((ActiveRecord::VERSION::MAJOR == 4 && ActiveRecord::VERSION::MINOR >= 1) ||
|
38
|
+
ActiveRecord::VERSION::MAJOR > 4)
|
38
39
|
ActiveRecord::Associations::Preloader.new.preload(records, association)
|
39
40
|
else
|
40
41
|
ActiveRecord::Associations::Preloader.new(records, association).run
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: graphql-preload
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Foster, Etienne Tripier
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-11-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|