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

Popular posts from this blog

neo4j - finding mutual friends in a cypher statement starting with three or more persons -

php - How to remove letter in front of the word laravel -

minify - Minimizing css files -