Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 0.9.0 raises ImportError #74

Open
crazyscientist opened this issue Aug 19, 2021 · 6 comments
Open

Version 0.9.0 raises ImportError #74

crazyscientist opened this issue Aug 19, 2021 · 6 comments

Comments

@crazyscientist
Copy link

When using these packages:

Package                        Version
------------------------------ ----------
graphene                       2.1.9
graphene-django                2.15.0
graphene-django-optimizer      0.9.0
graphql-core                   2.3.2
graphql-relay                  2.0.1

the following exception gets raised when running tests or accessing the GraphiQL interface:

Internal Server Error: /graphql/
Traceback (most recent call last):
  File "/home/andi/virtualenvs/smelt/lib/python3.8/site-packages/graphene_django/settings.py", line 80, in import_from_string
    module = importlib.import_module(module_path)
  File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 848, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/andi/workspace/smelt/smelt/smelt/schema.py", line 7, in <module>
    from smeltapp import schema
  File "/home/andi/workspace/smelt/smelt/smeltapp/schema.py", line 16, in <module>
    from graphene_django_optimizer import query, OptimizedDjangoObjectType, resolver_hints
  File "/home/andi/virtualenvs/smelt/lib/python3.8/site-packages/graphene_django_optimizer/__init__.py", line 2, in <module>
    from .query import query  # noqa: F401
  File "/home/andi/virtualenvs/smelt/lib/python3.8/site-packages/graphene_django_optimizer/query.py", line 11, in <module>
    from graphql import GraphQLResolveInfo, GraphQLSchema
ImportError: cannot import name 'GraphQLResolveInfo' from 'graphql' (/home/andi/virtualenvs/smelt/lib/python3.8/site-packages/graphql/__init__.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/andi/virtualenvs/smelt/lib/python3.8/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/home/andi/virtualenvs/smelt/lib/python3.8/site-packages/django/core/handlers/base.py", line 115, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/home/andi/virtualenvs/smelt/lib/python3.8/site-packages/django/core/handlers/base.py", line 113, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/andi/virtualenvs/smelt/lib/python3.8/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
    return view_func(*args, **kwargs)
  File "/home/andi/virtualenvs/smelt/lib/python3.8/site-packages/django/views/generic/base.py", line 62, in view
    self = cls(**initkwargs)
  File "/home/andi/virtualenvs/smelt/lib/python3.8/site-packages/graphene_django/views.py", line 104, in __init__
    schema = graphene_settings.SCHEMA
  File "/home/andi/virtualenvs/smelt/lib/python3.8/site-packages/graphene_django/settings.py", line 127, in __getattr__
    val = perform_import(val, attr)
  File "/home/andi/virtualenvs/smelt/lib/python3.8/site-packages/graphene_django/settings.py", line 66, in perform_import
    return import_from_string(val, setting_name)
  File "/home/andi/virtualenvs/smelt/lib/python3.8/site-packages/graphene_django/settings.py", line 89, in import_from_string
    raise ImportError(msg)
ImportError: Could not import 'smelt.schema.schema' for Graphene setting 'SCHEMA'. ImportError: cannot import name 'GraphQLResolveInfo' from 'graphql' (/home/andi/virtualenvs/smelt/lib/python3.8/site-packages/graphql/__init__.py).

With version 0.8.0 this exception does not get raised.

@sandnima
Copy link

Have the same problem

@KristobalJunta
Copy link

Seems like it was caused by adding support for GraphQL Core 3.
See e5c57fc

Unfortunately, v0.9.0 wasn't marked as breaking changes for some reason...

@tfoxy
Copy link
Owner

tfoxy commented Sep 19, 2021

Thanks for bringing this up. As @KristobalJunta said, the breaking change was brought by adding support for GraphQL Core 3. Will add a message to the readme so people are aware of this.

@tfoxy
Copy link
Owner

tfoxy commented Sep 19, 2021

Added note to readme. If someone knows a way to warn about version incompatibility with pip, please let me know. Will leave this issue open so that people can find it easier.

@crazyscientist
Copy link
Author

If someone knows a way to warn about version incompatibility with pip

I'm not aware of such a feature in pip. But you could use Python's warning module to generate a warning at runtime 🤔

@daniel-skale
Copy link

On the same boat using graphene-django==2.15.0 but with no graphene and currently using graphene-django-optimizer==0.6.2. Should the move be to scrap graphene-django (updates are too slow) and just use graphene v3 with graphene-django-optimizer==0.9.0?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants