def graphene_reducer(self, map, type): if isinstance(type, (List, NonNull)): return self.reducer(map, type.of_type) if type._meta.name in map: _type = map[type._meta.name] if isinstance(_type, GrapheneGraphQLType): assert _type.graphene_type == type, ( 'Found different types with the same name in the schema: {}, {}.' ).format(_type.graphene_type, type) return map if issubclass(type, ObjectType): internal_type = self.construct_objecttype(map, type) elif issubclass(type, InputObjectType): internal_type = self.construct_inputobjecttype(map, type) elif issubclass(type, Interface): internal_type = self.construct_interface(map, type) elif issubclass(type, Scalar): internal_type = self.construct_scalar(map, type) elif issubclass(type, Enum): internal_type = self.construct_enum(map, type) elif issubclass(type, Union): internal_type = self.construct_union(map, type) else: raise Exception( "Expected Graphene type, but received: {}.".format(type)) return GraphQLTypeMap.reducer(map, internal_type)
def reducer(self, map, type): if not type: return map if inspect.isfunction(type): type = type() if is_graphene_type(type): return self.graphene_reducer(map, type) return GraphQLTypeMap.reducer(map, type)