如何在graphene-django中为react-relay创建一个查看器字段?这不像预期的那样工作。我正在使用graphene-django v.2.2。姜戈 2.1。反应中继 v1.7.0-rc.1。
// landingpage.schema.py
class CollectionNode(DjangoObjectType):
class Meta:
model = Collection
interfaces = (relay.Node, )
class Viewer(graphene.ObjectType):
class Meta:
interfaces = [relay.Node, ]
collection = graphene.Field(CollectionNode)
def resolve_collection(self, info, **kwargs):
return Collection.objects.all()
class Query(object):
viewer = graphene.Field(Viewer)
def resolve_viewer(self, info, **kwargs):
return Viewer() # or info.parent_type