graphql-relay 0.9.1 → 0.9.2

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: ee15c8ecfc7211458db3f5c9ea677f58e0a836a0
4
- data.tar.gz: 408c83f5849052f11bf89fa8eb16e7228dd7dcd8
3
+ metadata.gz: 55d2f7666bd132151bd0c1426627f369d0f272b6
4
+ data.tar.gz: 4c605da951545cc1bd53c5a326bdb29784a39a96
5
5
  SHA512:
6
- metadata.gz: cdc02c0272c909596c5c05816f2881b2e619d01a35a08e4efaa8f75b685fe225d9581f573c96d8fc2f7365679801770999b7e8607c861b2a776144e99c1a0bd1
7
- data.tar.gz: 314b20cbbc0ce9fb73b5ffcdc63a6a0662cdfac9d057f6393bb98dc7135290d100a4a66fd7a14817709b38b3a9d65f30577ce6e090ac537a4b7822f08f02e9e9
6
+ metadata.gz: 846f5d4d7b1dba5972dabbd163ebf640869744c3f044fe105121a2afdcc025e63489184823faf961259ab8c151edda071b6fa78a6a8f6dca31ac17a84a82841c
7
+ data.tar.gz: 2740ae5e2635701d04ac5e683b245fd195e1ec3a2d02760799eb7a3e6a06533bdcc65bdd913f492f42733ce716a6af6a7e989d6f57c819c1a6eac6a1700e2f92
@@ -95,7 +95,9 @@ module GraphQL
95
95
  # get a type for a given object
96
96
  def type_from_object(object)
97
97
  type_result = @type_from_object_proc.call(object)
98
- if !type_result.is_a?(GraphQL::BaseType)
98
+ if type_result.nil?
99
+ nil
100
+ elsif !type_result.is_a?(GraphQL::BaseType)
99
101
  type_str = "#{type_result} (#{type_result.class.name})"
100
102
  raise "type_from_object(#{object}) returned #{type_str}, but it should return a GraphQL type"
101
103
  else
@@ -1,5 +1,5 @@
1
1
  module GraphQL
2
2
  module Relay
3
- VERSION = '0.9.1'
3
+ VERSION = '0.9.2'
4
4
  end
5
5
  end
@@ -113,6 +113,14 @@ describe GraphQL::Relay::GlobalNodeIdentification do
113
113
  end
114
114
 
115
115
  describe "type_from_object" do
116
+
117
+ describe "when the return value is nil" do
118
+ it "returns nil" do
119
+ result = GraphQL::Relay::GlobalNodeIdentification.instance.type_from_object(123)
120
+ assert_equal(nil, result)
121
+ end
122
+ end
123
+
116
124
  describe "when the return value is not a BaseType" do
117
125
  it "raises an error " do
118
126
  err = assert_raises(RuntimeError) {
@@ -21,8 +21,12 @@ NodeIdentification = GraphQL::Relay::GlobalNodeIdentification.define do
21
21
  :not_a_type
22
22
  elsif object.is_a?(Base)
23
23
  BaseType
24
+ elsif STAR_WARS_DATA["Faction"].values.include?(object)
25
+ Faction
26
+ elsif STAR_WARS_DATA["Ship"].values.include?(object)
27
+ Ship
24
28
  else
25
- STAR_WARS_DATA["Faction"].values.include?(object) ? Faction : Ship
29
+ nil
26
30
  end
27
31
  end
28
32
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphql-relay
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.1
4
+ version: 0.9.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Mosolgo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-06 00:00:00.000000000 Z
11
+ date: 2016-04-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: graphql