通过ForeignKey进行GraphQL过滤不会出错,但是不起作用

时间:2018-12-27 10:09:02

标签: python django graphql

这是按主题ID过滤的。 Graphql不会出错,但是不会按topic_id进行过滤:

Handler

但是当我按主题名称过滤时:

ORDER BY tt.tstatus

与名称完美配合。但是,我需要按ID进行过滤。

Graphql查询:

class ArticleNode(DjangoObjectType):
    class Meta:
        model = Article
        filter_fields = ['topic__id']
        interfaces = (relay.Node, )

    oid = graphene.Field(graphene.Int)

    def resolve_oid(self, info, **kwargs):
        return self.id

不会出错但无法正常运行的GraphQl查询:

class ArticleNode(DjangoObjectType):
    class Meta:
        model = Article
        filter_fields = ['topic__name']
        interfaces = (relay.Node, )

    oid = graphene.Field(graphene.Int)

    def resolve_oid(self, info, **kwargs):
        return self.id

0 个答案:

没有答案