graphql-preload 1.0.3 → 1.0.4

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: 6bbbde895d17e5914f30802362a2453cc4f3de89
4
- data.tar.gz: b11f2782b0a1cb286d867e83fff3da24c1650c5c
3
+ metadata.gz: b779bc0472181687609ba597178bd337c1653dfc
4
+ data.tar.gz: cdb4a938912f4337650e9f9f710083f8f2fe33f1
5
5
  SHA512:
6
- metadata.gz: 2b6f8a34abdaf6ce6624d38cd230d49864dde3e2b3a93561019b23562d6870819605da476125512c70d621933af1019f0c508bee872baaf518308820b4854a4a
7
- data.tar.gz: a89501116230eca584019915d5e66b2c4ef019ed70c12151cc7a474587e1189f3f6b584a8c739ef5887b0869be357524afc3525883e4689435654dec642ae11f
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 > 3
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
@@ -1,5 +1,5 @@
1
1
  module GraphQL
2
2
  module Preload
3
- VERSION = '1.0.3'.freeze
3
+ VERSION = '1.0.4'.freeze
4
4
  end
5
5
  end
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.3
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-08-01 00:00:00.000000000 Z
11
+ date: 2017-11-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord