我正在使用 Graphene、Django 和graphene-subscriptions来定义 GraphQL 订阅。Book
每当创建具有特定内容的新内容时,我都会尝试接收更新Author
。我已按照入门指南进行操作,并且正在尝试使用以下代码:
class SubscriptionBook(graphene.ObjectType):
NewBooks = graphene.Field(BookType, Author = graphene.String(required=True))
def resolve_NewBooks(root, info, Author):
return root.filter(
lambda event:
event.operation == CREATED and
isinstance(event.instance, Book) and
event.instance.AuthorID == Author
).map(lambda event: event.instance)
但这似乎不起作用。这条线似乎失败了:
event.instance.AuthorID == Author
我究竟做错了什么?