graphql-activerecord 0.7.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/graphql/activerecord.rb +8 -3
- data/lib/graphql/models/hash_combiner.rb +3 -3
- data/lib/graphql/models/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f86267939f32f4c1833c71f8002ddd96c5ce0463
|
4
|
+
data.tar.gz: d644a4fb9cc3ea8e2eb487dd889a59f1d804807d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 35aef7c3eb5ac3778258192a4fe7df1d57269d04fc4964a5d85a62d68a49c16df6f7b27ae5e0c6ed4d91caf534f84a11e9d18a69ab8f0be1cb86d8f3b74ea62a
|
7
|
+
data.tar.gz: 36c5cff269cb4a7682b2c144fc491d3c09eea733f39fdfed5a5b38ebc029901420b237b203d98aed0f5c99d49392d05a56663d6b9f9a173690e2e341a3f4a4f9
|
data/lib/graphql/activerecord.rb
CHANGED
@@ -51,9 +51,14 @@ module GraphQL
|
|
51
51
|
GraphQL::Models::DefinitionHelpers.load_and_traverse(starting_model, path, context)
|
52
52
|
end
|
53
53
|
|
54
|
-
def self.load_relation(relation)
|
55
|
-
|
56
|
-
|
54
|
+
def self.load_relation(relation, fast_query: false)
|
55
|
+
if fast_query
|
56
|
+
request = AttributeLoader::Request.new(relation.where_values_hash, Helpers.orders_to_sql(relation.orders))
|
57
|
+
AttributeLoader.for(relation.klass).load(request)
|
58
|
+
else
|
59
|
+
request = RelationLoadRequest.new(relation)
|
60
|
+
request.load
|
61
|
+
end
|
57
62
|
end
|
58
63
|
|
59
64
|
def self.field_info(graph_type, field_name)
|
@@ -10,17 +10,17 @@ module GraphQL::Models::HashCombiner
|
|
10
10
|
private
|
11
11
|
|
12
12
|
def combine_core(hashes, keys)
|
13
|
-
return [] if keys.
|
13
|
+
return [] if keys.nil? || keys.empty?
|
14
14
|
|
15
15
|
# If there's only one key in each of the hashes, then combine that into a single hash with an array
|
16
16
|
if keys.length == 1
|
17
17
|
values = hashes.map { |h| h[keys[0]] }
|
18
|
-
return [{ keys[0] => values.uniq }]
|
18
|
+
return [{ keys[0] => values.flatten.uniq }]
|
19
19
|
end
|
20
20
|
|
21
21
|
# Get the most commonly occuring value in the hash, and remove it from the keys.
|
22
22
|
# Return one hash for each unique value.
|
23
|
-
min_key = keys.min_by { |k| hashes.map { |h| h[k] }.uniq.count }
|
23
|
+
min_key = keys.min_by { |k| hashes.map { |h| h[k] }.flatten.uniq.count }
|
24
24
|
inner_keys = keys.dup
|
25
25
|
inner_keys.delete(min_key)
|
26
26
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: graphql-activerecord
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Foster
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-08-
|
11
|
+
date: 2016-08-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -214,7 +214,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
214
214
|
version: '0'
|
215
215
|
requirements: []
|
216
216
|
rubyforge_project:
|
217
|
-
rubygems_version: 2.
|
217
|
+
rubygems_version: 2.5.1
|
218
218
|
signing_key:
|
219
219
|
specification_version: 4
|
220
220
|
summary: ActiveRecord helpers for GraphQL + Relay
|