aiohttpgraphql AsyncioExecutor GraphQlLocatederError:“NoneType”对象不是callab

2024-05-28 20:02:51 发布

您现在位置:Python中文网/ 问答频道 /正文

我从asyncio+GraphQL开始,但连最简单的示例都无法使用:

from aiohttp import web
from aiohttp_graphql import GraphQLView
from graphql.execution.executors.asyncio import AsyncioExecutor
from graphql import GraphQLSchema, GraphQLObjectType, GraphQLField, GraphQLString

async 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)

控制台:

^{pr2}$

/graphql-graphiql接口中的错误消息:

{
  "errors": [
    {
      "message": "wait_until_finished() missing 1 required positional argument: 'self'"
    }
  ]
}

Tags: fromimportwebasyncioapphelloaiohttpgraphql

热门问题