我正在尝试使用与此类似的东西:
class User(DjangoObjectType):
class Meta:
model = auth_models.User
filter_fields = ('email', )
interfaces = (Node, )
connection = UserConnection
class UserConnection(Connection):
extra = graphene.String()
class Meta:
node = User
class Query(graphene.ObjectType):
users_connection = DjangoFilterConnectionField(
User,
where=UserWhereInput()
)
根据我的理解,用户节点需要在其元数据上传递UserConnection,而UserConnection需要在其元数据上传递User。
但是,它会创建一个交叉引用。有帮助吗?
答案 0 :(得分:2)
答案可以在这里找到
https://github.com/graphql-python/graphene-django/issues/304
class UserConnection(Connection):
extra = graphene.String()
class Meta:
abstract = True
class User(DjangoObjectType):
class Meta:
model = auth_models.User
filter_fields = ('email', )
interfaces = (Node, )
connection_class = UserConnection
class Query(graphene.ObjectType):
users_connection = DjangoFilterConnectionField(User, where=UserWhereInput())