I want to use graphene with relay together with a custom database connector. My schema is looking like:
class DBItem(DjangoObjectType):
class Meta:
model = DB
filter_fields = {
'id': ['exact'],
'LOGID': ['exact']
}
interfaces = (relay.Node, )
class DBConnection(relay.Connection):
class Meta:
node = DBItem
When I use only grahene my resolver works good when I build a list of the objects:
class Query(graphene.ObjectType):
sf = graphene.List(DBItem)
def resolve_sf(self, info):
db = MyConnector()
items = db.read_items()
db_items_as_obj_list = []
for item in items:
i = DBItem.__new__(DBItem)
i.__dict__.update(item)
db_items_as_obj_list.append(i)
return db_items_as_obj_list
What I understood is, that in order to use relay, I have to define a relay Connection, which I did, otherwise I will get a "table not found" error. The MyConnector().read_items() returns a dictionary. But what I dont understand is which type of object shall the resolver return.
categories = relay.ConnectionField(DBConnection)
I'm always getting:
graphql.error.located_error.GraphQLLocatedError: Resolved value from the connection field have to be iterable or instance of DBConnection. Received "None"