【问题标题】:Python Ariadne GraphQL "cannot import name 'GraphQLNamedType'"Python Ariadne GraphQL“无法导入名称'GraphQLNamedType'”
【发布时间】:2020-10-04 19:14:12
【问题描述】:

我将 Ariadne 与 Flask 一起使用。

当我按照Ariadne's doc for Flask 中的指示尝试from ariadne import QueryType, graphql_sync, make_executable_schema 时,我收到以下错误:

ImportError: cannot import name 'GraphQLNamedType'

我正在使用:

  • Python 3.5.1

  • ariadne-0.11.0

  • graphql-core-2.3.2

【问题讨论】:

    标签: python python-3.x flask ariadne-graphql


    【解决方案1】:

    似乎问题来自graphql-core 版本,需要>=3。

    我无法安装 >=3 版本,因此我将 Python 升级到 3.8。安装 Ariadne 时,我得到了相同的版本 0.11.0,但现在是 graphql-core 版本 3.0.5,不再出现错误。

    【讨论】:

    • 你真的没有graphql-core 3.1.1的任何错误吗?我安装了graphql-core 3.1.2然后我得到了一个新的错误,现在我有3.0.5并且没有错误。
    • 对不起,我有刚刚检查的3.0.5版本,我编辑了答案
    【解决方案2】:

    目前 Ariadne 与许多 graphql-core 不兼容,因此 Ariadne 工作的版本应该在 3.0 和 3.1 之间。

    pip install "graphql-core<3.1"
    

    她是一些来源:

    https://github.com/mirumee/ariadne/issues/345

    https://graphql-core-3.readthedocs.io/en/latest/intro.html#getting-started

    【讨论】:

      猜你喜欢
      • 2016-10-08
      • 2016-05-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多