我应该如何解决石墨烯中带有前导下划线的字段?

How should I resolve a field with leading underscore in graphene?

我有一个字段_id

class Article(graphene.ObjectType):
    _id = graphene.Int()
    article_id = graphene.Int()

    def resolve__id(self, info):
        return self.article_id

这个不起作用,它会将 _id 解释为 Id

Graphene 尝试将所有字段转换为驼峰式大小写以保持与 JavaScript 的约定:http://docs.graphene-python.org/en/latest/types/schema/#auto-camelcase-field-names

这可以在架构级别关闭,或者您可以根据需要显式覆盖字段名称:

class Article(graphene.ObjectType):
    id = graphene.Int(name='_id')