relay - Custom ConnectionField in graphene -
i'm not understanding how use custom fields in connectionfield in graphene. have like:
class shipconnection(connection): = string() class meta: node = ship ships = ['tug boat', 'row boat', 'canoe'] class query(abstracttype): ships = relay.connectionfield(shipconnection) def resolve_ships(self, args, context, info): return shipconnection( extra='some text', edges=??? ) normally, you'd say:
def resolve_ships(self, args, context, info): return ships but how return in and return list?
the answer turns out to use undocumented class method of graphene's connectionfield class, called resolve_connection. following works:
def resolve_ships(self, args, context, info): field = relay.connectionfield.resolve_connection( shipconnection, args, ships ) field.extra = 'whatever' return field
Comments
Post a Comment