Created
March 17, 2022 12:36
-
-
Save mannyanebi/e5b7181b63bc5eaa419057e38b6481cc to your computer and use it in GitHub Desktop.
A sample of how to create your own custom graphene connection
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Member(DjangoObjectType): | |
class Meta: | |
model = models.Member | |
filter_fields = [] | |
interfaces = (graphene.Node, ) | |
contacts = graphene.ConnectionField('api.graphql.Contact') | |
def resolve_contacts(instance, info): | |
info.context.root = instance | |
return instance.contacts | |
class Contact(graphene.Connection): | |
class Meta: | |
node = Member | |
class Edge: | |
circles = graphene.List(Circle) | |
def resolve_circles(instance, info): | |
return info.context.root.circles.intersection(instance.node.circles.all()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
graphql-python/graphene#378 (comment)