graphql-remote_loader 0.0.3 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/graphql/remote_loader/loader.rb +28 -22
- data/lib/graphql/remote_loader/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: cd7a27a207b0fccaa2e6329d51d3de738f333c09
|
4
|
+
data.tar.gz: b90fd6caae8031cc12b98c4d3a64a846cf92466a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dab4bded8d2e3f34739b7adcd147597576b76a31b0a76290cd114a72b877a6ed2ffead7760ccc45644aff6b95558dd1f4bc8725e5a330ce3596dfbc76d916376
|
7
|
+
data.tar.gz: a6337ed60323d83c87f9ccb845021884d7cafcdd0ef74bec74d4a5b38734969b97a353417ab8b4549b4f0a10f83f952d22e44cf272b340a1b9dd31288ac9fe8e
|
data/Gemfile.lock
CHANGED
@@ -41,29 +41,35 @@ module GraphQL
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def filter_keys_on_response(obj, prime)
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
44
|
+
case obj
|
45
|
+
when Array
|
46
|
+
obj.map { |element| filter_keys_on_response(element, prime) }
|
47
|
+
when Hash
|
48
|
+
filtered_results = {}
|
49
|
+
|
50
|
+
# Select field keys on the results hash
|
51
|
+
fields = obj.keys.select { |k| k.match /\Ap[0-9]+.*[^?]\z/ }
|
52
|
+
|
53
|
+
# Filter methods that were not requested in this sub-query
|
54
|
+
fields = fields.select do |field|
|
55
|
+
prime_factor = field.match(/\Ap([0-9]+)/)[1].to_i
|
56
|
+
(prime_factor % prime) == 0
|
57
|
+
end
|
58
|
+
|
59
|
+
# redefine methods on new obj, recursively filter sub-selections
|
60
|
+
fields.each do |method|
|
61
|
+
method_name = method.match(/\Ap[0-9]+(.*)/)[1]
|
62
|
+
|
63
|
+
method_value = obj[method]
|
64
|
+
filtered_value = filter_keys_on_response(method_value, prime)
|
65
|
+
|
66
|
+
filtered_results[underscore(method_name)] = filtered_value
|
67
|
+
end
|
68
|
+
|
69
|
+
filtered_results
|
70
|
+
else
|
71
|
+
return obj
|
54
72
|
end
|
55
|
-
|
56
|
-
# redefine methods on new obj, recursively filter sub-selections
|
57
|
-
fields.each do |method|
|
58
|
-
method_name = method.match(/\Ap[0-9]+(.*)/)[1]
|
59
|
-
|
60
|
-
method_value = obj[method]
|
61
|
-
filtered_value = filter_keys_on_response(method_value, prime)
|
62
|
-
|
63
|
-
filtered_results[underscore(method_name)] = filtered_value
|
64
|
-
end
|
65
|
-
|
66
|
-
filtered_results
|
67
73
|
end
|
68
74
|
|
69
75
|
def underscore(str)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: graphql-remote_loader
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathaniel Woodthorpe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-06-
|
11
|
+
date: 2018-06-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: graphql
|