graphql_grpc 0.1.8 → 0.1.9

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
  SHA256:
3
- metadata.gz: 9b55859c768e366b0db45e4df7c81bd16921b219493995ebfe5d7345220db240
4
- data.tar.gz: 98576c693daaae01f1ec1bdde5e2596c1bd456fbd5b25db56e545ebb0e7bffcc
3
+ metadata.gz: 55decad51b1fe59ba29cd95b3dd7bf6c93a1417fd8fcc663735d6069d3560090
4
+ data.tar.gz: 3ca7a9a20df756213f8da850a9b2a36d4b1940eed229ef2305f1aa66608cb7e5
5
5
  SHA512:
6
- metadata.gz: 319343686545bfe90899e076fed025f07da73c3b2517a3f919dc899f8f1d55eb7c3bc874b945c13ee81272366325646781ae677677a24646d9f795badf8ca912
7
- data.tar.gz: 61ef9ae690a6806b0aed52fb86cf2f91700a083b227688fd40eee3ec0df7a6ee2c1544d1cd038d4f5e9858632d4e5741d2157b77e549ab38bd8cda0b4ac1b170
6
+ metadata.gz: 4cacb192944e825d29bfaf6922706f4fe82b4bc5dd11ba8f9efe1a789554147e30d914b3e4ea35ca4f4b689f6cbbed471d8f2ac21b9dee57452be778d02461ec
7
+ data.tar.gz: c16e2b65c23e2408bb8d1a5614a15a29a0a5b388a3f32c2e7920781905a031718d4a38886e71dc134e98385c4483e9b05e1266047f3977d72c655e0346499f3d
data/Guardfile CHANGED
@@ -64,7 +64,7 @@ guard :rspec, cmd: 'bundle exec rspec' do
64
64
  watch(rails.view_dirs) { |m| rspec.spec.call("features/#{m[1]}") }
65
65
  watch(rails.layouts) { |m| rspec.spec.call("features/#{m[1]}") }
66
66
 
67
- watch(%r{^lib/graphql_grpc/**/(.+)\.rb}) { |_m| rspec.spec.call('graphql_grpc') }
67
+ watch(%r{^lib/graphql_grpc/(.+)\.rb}) { |_m| rspec.spec.call('graphql_grpc') }
68
68
  watch(%r{^doc/(.+)}) { |_m| rspec.spec.call('graphql_grpc') }
69
69
 
70
70
  # Turnip features and steps
@@ -9,10 +9,15 @@ module GraphqlGrpc
9
9
  def call(_type, field, obj, args, ctx)
10
10
  if obj
11
11
  field_sym = field.name.to_sym
12
- value = obj.try(field_sym) || obj[field_sym.to_s] || begin
13
- obj[field_sym]
14
- rescue TypeError => e
15
- nil
12
+ # Try to access the field as a method, then with Hash notation using
13
+ # a Symbol and finally as a String.
14
+
15
+ value = if obj.is_a?(Hash)
16
+ # Prefer Hash value over method in case Hash keys conflict
17
+ # with method names on Hash.
18
+ obj[field_sym] || obj.try(field_sym)
19
+ else
20
+ obj[field_sym.to_s]
16
21
  end
17
22
  return value.is_a?(Symbol) ? value.to_s : value
18
23
  end
@@ -34,7 +34,9 @@ module GraphqlGrpc
34
34
  #
35
35
  # Return an array of all (recursive) types known within this type
36
36
  #
37
- def sub_types
37
+ def sub_types(known_types=[])
38
+ return known_types if known_types.include?(name)
39
+
38
40
  # Iterate through the Google::Protobuf::FieldDescriptor list
39
41
  entries.map do |fd|
40
42
  # fd.name = 'current_entity_to_update'
@@ -43,12 +45,11 @@ module GraphqlGrpc
43
45
  # fd.submsg_name = "com.foo.bar.Baz"
44
46
  # fd.subtype = #<Google::Protobuf::Descriptor:0x007fabb3947f08>
45
47
  if fd.subtype.class == Google::Protobuf::Descriptor
46
- # There is a subtype; recurse
47
- [name, fd.submsg_name] + fd.subtype.sub_types
48
+ [name, fd.subtype.sub_types(known_types + [name])].flatten
48
49
  else
49
50
  [name, fd.submsg_name]
50
51
  end
51
- end.flatten.compact
52
+ end.flatten.compact.uniq
52
53
  end
53
54
 
54
55
  def type_name
@@ -1,3 +1,3 @@
1
1
  module GraphqlGrpc
2
- VERSION = '0.1.8'.freeze
2
+ VERSION = '0.1.9'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphql_grpc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zane Claes
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2019-06-20 00:00:00.000000000 Z
12
+ date: 2019-06-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport