Import (cannot import name 'ResolveInfo' from 'graphql') error when using newest graphene and graphene-django version

huangapple go评论170阅读模式
英文:

Import (cannot import name 'ResolveInfo' from 'graphql') error when using newest graphene and graphene-django version

问题

我在更新我的依赖项后,我的Django应用程序出现了一些问题。以下是我的已安装应用程序:

INSTALLED_APPS = [
'graphene_django',
'rest_framework',
'corsheaders',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'dojo_manager.dojo',
]

以及我的requirements.txt:

aniso8601==8.0.0
asgiref==3.2.3
Django==3.0.2
django-cors-headers==3.2.0
django-filter==2.2.0
django-graphql-jwt==0.3.0
djangorestframework==3.11.0
djangorestframework-jwt==1.11.0
graphene==2.1.8
graphene-django==2.8.0
graphene-django-extras==0.4.8
graphql-core==3.0.1
graphql-relay==3.0.0
pip-upgrade-outdated==1.5
pipupgrade==1.5.2
promise==2.3
PyJWT==1.7.1
python-dateutil==2.8.1
pytz==2019.3
Rx==3.0.1
singledispatch==3.4.0.3
six==1.13.0
sqlparse==0.3.0

我收到以下错误消息:

ImportError: 无法从'graphql'中导入名称'ResolveInfo' (E:\Ben\GitHub-Repos\dojo-manager\env\lib\site-packages\graphql_init_.py)

我已经注意到https://github.com/graphql-python/graphene-django/issues/737和https://github.com/graphql-python/graphene/issues/546,但似乎都不能解决我的问题。任何帮助将不胜感激。

英文:

I am having some issues with my django app since updating my dependencies.
Here aer my installed apps:

  1. INSTALLED_APPS = [
  2. 'graphene_django',
  3. 'rest_framework',
  4. 'corsheaders',
  5. 'django.contrib.admin',
  6. 'django.contrib.auth',
  7. 'django.contrib.contenttypes',
  8. 'django.contrib.sessions',
  9. 'django.contrib.messages',
  10. 'django.contrib.staticfiles',
  11. 'dojo_manager.dojo',
  12. ]

and my requirements.txt:

  1. aniso8601==8.0.0
  2. asgiref==3.2.3
  3. Django==3.0.2
  4. django-cors-headers==3.2.0
  5. django-filter==2.2.0
  6. django-graphql-jwt==0.3.0
  7. djangorestframework==3.11.0
  8. djangorestframework-jwt==1.11.0
  9. graphene==2.1.8
  10. graphene-django==2.8.0
  11. graphene-django-extras==0.4.8
  12. graphql-core==3.0.1
  13. graphql-relay==3.0.0
  14. pip-upgrade-outdated==1.5
  15. pipupgrade==1.5.2
  16. promise==2.3
  17. PyJWT==1.7.1
  18. python-dateutil==2.8.1
  19. pytz==2019.3
  20. Rx==3.0.1
  21. singledispatch==3.4.0.3
  22. six==1.13.0
  23. sqlparse==0.3.0

I am getting

  1. ImportError: cannot import name 'ResolveInfo' from 'graphql' (E:\Ben\GitHub-Repos\dojo-manager\env\lib\site-packages\graphql\__init__.py)

I am aware of https://github.com/graphql-python/graphene-django/issues/737 and https://github.com/graphql-python/graphene/issues/546 , none of which seem to solve it in my case.

Any help greatly appreciated.

答案1

得分: 7

我成功解决了问题,通过将 graphql-core==3.0.1 降级到 graphql-core<3(以及所有依赖项)。

在执行 pip install -r requirements.txt 时,我一定是错过了错误。

英文:

Ok I was able to fix it by downgrading graphql-core==3.0.1 to graphql-core&lt;3 (and all the depencencies).

I must have missed the errors when performing pip install -r requirements.txt

答案2

得分: 0

尝试替换头部

  1. from graphql.type import GraphQLResolveInfo as ResolveInfo
  2. # from graphql.execution.base import ResolveInfo
英文:

Try to replace the header

  1. from graphql.type import GraphQLResolveInfo as ResolveInfo
  2. # from graphql.execution.base import ResolveInfo

huangapple
  • 本文由 发表于 2020年1月4日 00:38:28
  • 转载请务必保留本文链接:https://go.coder-hub.com/59582142.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定