为了账号安全,请及时绑定邮箱和手机立即绑定

aiohttp-graphql AsyncioExecutor

aiohttp-graphql AsyncioExecutor

慕无忌1623718 2021-10-10 15:30:12
我从 asyncio + GraphQL 开始,但即使是最简单的例子也无法工作:from aiohttp import webfrom aiohttp_graphql import GraphQLViewfrom graphql.execution.executors.asyncio import AsyncioExecutorfrom graphql import GraphQLSchema, GraphQLObjectType, GraphQLField, GraphQLStringasync def resolve_hello(root, info):    return 'World!'Schema = GraphQLSchema(    query=GraphQLObjectType(        name='RootQueryType',        fields={            'hello': GraphQLField(                type=GraphQLString,                resolver=resolve_hello),        },    ))app = web.Application()GraphQLView.attach(    app,    route_path='/graphql',    schema=Schema,    graphiql=True,    executor=AsyncioExecutor)if __name__ == '__main__':    web.run_app(app)安慰:$ venv/bin/python example.py======== Running on http://0.0.0.0:8080 ========(Press CTRL+C to quit)An error occurred while resolving field RootQueryType.helloTraceback (most recent call last):  File "/.../venv/lib/python3.7/site-packages/graphql/execution/executor.py", line 447, in resolve_or_error    return executor.execute(resolve_fn, source, info, **args)  File "/.../venv/lib/python3.7/site-packages/graphql/execution/executors/asyncio.py", line 69, in execute    result = fn(*args, **kwargs)TypeError: 'NoneType' object is not callableTraceback (most recent call last):  File "/.../venv/lib/python3.7/site-packages/graphql/execution/executor.py", line 447, in resolve_or_error    return executor.execute(resolve_fn, source, info, **args)  File "/.../venv/lib/python3.7/site-packages/graphql/execution/executors/asyncio.py", line 69, in execute    result = fn(*args, **kwargs)graphql.error.located_error.GraphQLLocatedError: 'NoneType' object is not callable/graphql graphiql 界面中的错误消息:{  "errors": [    {      "message": "wait_until_finished() missing 1 required positional argument: 'self'"    }  ]}
查看完整描述

1 回答

?
慕少森

TA贡献2019条经验 获得超9个赞

问题出在执行程序设置中:


GraphQLView.attach(

    ...

    executor=AsyncioExecutor)

应该


GraphQLView.attach(

    ...

    executor=AsyncioExecutor())


查看完整回答
反对 回复 2021-10-10
  • 1 回答
  • 0 关注
  • 144 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信