Graphene-django: Recursive Node Relationships

Created on 11 Nov 2016  路  1Comment  路  Source: graphql-python/graphene-django

Is something like this possible

class UserNode(DjangoObjectType):

     friends = graphene.List(UserNode)

     class Meta:
         interfaces = (Node, )
         model = UserModel

if there currently isn't a way to do this, I propose doing something similar to how django models resolve strings to reference models

Most helpful comment

This is solved by using a lambda, thanks @syrusakbary for pointing this out!

class UserNode(DjangoObjectType):

    friends = graphene.List(lambda: UserNode)
    class Meta:
         interfaces = (Node, )
         model = UserModel

>All comments

This is solved by using a lambda, thanks @syrusakbary for pointing this out!

class UserNode(DjangoObjectType):

    friends = graphene.List(lambda: UserNode)
    class Meta:
         interfaces = (Node, )
         model = UserModel
Was this page helpful?
0 / 5 - 0 ratings