@@ -81,16 +81,18 @@ def graphene_reducer(self, map, type):
81
81
82
82
if issubclass (type , ObjectType ):
83
83
internal_type = self .construct_objecttype (map , type )
84
- if issubclass (type , InputObjectType ):
84
+ elif issubclass (type , InputObjectType ):
85
85
internal_type = self .construct_inputobjecttype (map , type )
86
- if issubclass (type , Interface ):
86
+ elif issubclass (type , Interface ):
87
87
internal_type = self .construct_interface (map , type )
88
- if issubclass (type , Scalar ):
88
+ elif issubclass (type , Scalar ):
89
89
internal_type = self .construct_scalar (map , type )
90
- if issubclass (type , Enum ):
90
+ elif issubclass (type , Enum ):
91
91
internal_type = self .construct_enum (map , type )
92
- if issubclass (type , Union ):
92
+ elif issubclass (type , Union ):
93
93
internal_type = self .construct_union (map , type )
94
+ else :
95
+ raise Exception ("Expected Graphene type, but received: {}." .format (type ))
94
96
95
97
return GraphQLTypeMap .reducer (map , internal_type )
96
98
@@ -145,8 +147,10 @@ def construct_objecttype(self, map, type):
145
147
def interfaces ():
146
148
interfaces = []
147
149
for interface in type ._meta .interfaces :
148
- i = self .construct_interface (map , interface )
149
- interfaces .append (i )
150
+ self .graphene_reducer (map , interface )
151
+ internal_type = map [interface ._meta .name ]
152
+ assert internal_type .graphene_type == interface
153
+ interfaces .append (internal_type )
150
154
return interfaces
151
155
152
156
return GrapheneObjectType (
@@ -190,10 +194,16 @@ def construct_union(self, map, type):
190
194
_resolve_type = None
191
195
if type .resolve_type :
192
196
_resolve_type = partial (resolve_type , type .resolve_type , map , type ._meta .name )
193
- types = []
194
- for i in type ._meta .types :
195
- internal_type = self .construct_objecttype (map , i )
196
- types .append (internal_type )
197
+
198
+ def types ():
199
+ union_types = []
200
+ for objecttype in type ._meta .types :
201
+ self .graphene_reducer (map , objecttype )
202
+ internal_type = map [objecttype ._meta .name ]
203
+ assert internal_type .graphene_type == objecttype
204
+ union_types .append (internal_type )
205
+ return union_types
206
+
197
207
return GrapheneUnionType (
198
208
graphene_type = type ,
199
209
name = type ._meta .name ,
0 commit comments