将最新的ariadne 0.16.1
与graphql-core 3.2.3
和Python 3.10一起使用时,我收到以下错误。这是一个FastAPI应用程序。
from fastapi import FastAPI
from ariadne.asgi import GraphQL
第二行抛出错误
from graphql.type import GraphQLEnumType, GraphQLNamedType, GraphQLSchema ModuleNotFoundError: No module named 'graphql.type'
我尝试更改库的版本,包括升级和降级,但没有成功。
感谢
更新
问题得到解决。项目中有一个graphql目录。重命名它解决了这个问题。谢谢
如果代码在graphql/
目录中,那么Python会对模块感到困惑,并试图在您的目录中找到graphql/types.py
,而不是包目录。
如果是这种情况,那么将graphql/
目录重命名为其他目录,例如graphql_api/
。