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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b4e6ea2888b09a78e64eeec68a7905e5932c0aa2
4
- data.tar.gz: 93ff402aaff2686821e835ecf1200b894f00c61a
3
+ metadata.gz: cd7a27a207b0fccaa2e6329d51d3de738f333c09
4
+ data.tar.gz: b90fd6caae8031cc12b98c4d3a64a846cf92466a
5
5
  SHA512:
6
- metadata.gz: 103d053506f99d3b285122a1eef0bf5dbb6cd685978a0cd78a316644211eb97a6bd6ccc1a0e18374b922011e94a7e54278b03650e147aa47b765f048179a3a18
7
- data.tar.gz: f22cc0abee65eaa738c640abff3dce91fa7fd17f58523d4abde0094f1000c4d7f7a05e80fe8608172a95dc51383f8db0ad28a469ff660199433c1449235cb1e7
6
+ metadata.gz: dab4bded8d2e3f34739b7adcd147597576b76a31b0a76290cd114a72b877a6ed2ffead7760ccc45644aff6b95558dd1f4bc8725e5a330ce3596dfbc76d916376
7
+ data.tar.gz: a6337ed60323d83c87f9ccb845021884d7cafcdd0ef74bec74d4a5b38734969b97a353417ab8b4549b4f0a10f83f952d22e44cf272b340a1b9dd31288ac9fe8e
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- graphql-remote_loader (0.0.2)
4
+ graphql-remote_loader (0.0.5)
5
5
  graphql (~> 1.6)
6
6
  graphql-batch (~> 0.3)
7
7
 
@@ -41,29 +41,35 @@ module GraphQL
41
41
  end
42
42
 
43
43
  def filter_keys_on_response(obj, prime)
44
- return obj unless obj.is_a? Hash
45
- filtered_results = {}
46
-
47
- # Select field keys on the results hash
48
- fields = obj.keys.select { |k| k.match /\Ap[0-9]+.*[^?]\z/ }
49
-
50
- # Filter methods that were not requested in this sub-query
51
- fields = fields.select do |field|
52
- prime_factor = field.match(/\Ap([0-9]+)/)[1].to_i
53
- (prime_factor % prime) == 0
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)
@@ -1,5 +1,5 @@
1
1
  module GraphQL
2
2
  module RemoteLoader
3
- VERSION = "0.0.3"
3
+ VERSION = "0.0.5"
4
4
  end
5
5
  end
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.3
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-13 00:00:00.000000000 Z
11
+ date: 2018-06-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: graphql