简体   繁体   中英

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

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

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',
]

and my 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   

I am getting

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.

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

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

Try to replace the header

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM