我有一个领域 _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')