简体   繁体   English

通过ID,石墨烯Sqlalchemy查询错误

[英]Error query by id, Graphene Sqlalchemy

I'm trying to make an query by id, I'm doing it like that, but I have the same error in the two options 我正在尝试通过id进行查询,就像那样,但是在两个选项中我有相同的错误

First option 第一选择

class Query(graphene.ObjectType):

    node = graphene.relay.Node.Field()
    user = graphene.Field(Users, id = graphene.Int())

    def resolve_user(self, args, context, info):
        query = Users.get_query(context)
        id = args.get('id')
        return query.get(id)

Second option 第二选择

class Query(graphene.ObjectType):

    node = relay.Node.Field()
    user = SQLAlchemyConnectionField(Users)
    find_user = graphene.Field(lambda: Users, id = graphene.Int())

    def resolve_find_user(self, args, context, info):
        query = Users.get_query(context)
        print("Args--------------------",str(args))
        id = args.get('id')
        return query.filter(UsersModel.id == id).first()

Error 错误

graphql.error.located_error.GraphQLLocatedError: resolve_find_user() got an unexpected keyword argument│'id'

我的错误的解决方案, 这里是新版本2.0的文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM