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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 55d2f7666bd132151bd0c1426627f369d0f272b6
|
4
|
+
data.tar.gz: 4c605da951545cc1bd53c5a326bdb29784a39a96
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
@@ -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
|
-
|
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.
|
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-
|
11
|
+
date: 2016-04-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: graphql
|