graphql-python / graphene-django

Build powerful, efficient, and flexible GraphQL APIs with seamless Django integration.
http://docs.graphene-python.org/projects/django/en/latest/
MIT License
4.31k stars 769 forks source link

Circular Import: cannot import name 'GraphQLObjectType' from partially initialized module 'graphql.type' #1436

Open yankeexe opened 1 year ago

yankeexe commented 1 year ago

Note: for support questions, please use stackoverflow. This repository's issues are reserved for feature requests and bug reports.

File "/ve/lib/python3.8/site-packages/graphene_django/__init__.py", line 1, in <module>
--
1970 | from .fields import DjangoConnectionField, DjangoListField
1971 | File "/ve/lib/python3.8/site-packages/graphene_django/fields.py", line 4, in <module>
1972 | from graphql_relay.connection.arrayconnection import (
1973 | File "/ve/lib/python3.8/site-packages/graphql_relay/connection/arrayconnection.py", line 10, in <module>
1974 | from ..utils.base64 import base64, unbase64
1975 | File "/ve/lib/python3.8/site-packages/graphql_relay/__init__.py", line 16, in <module>
1976 | from .connection.connection import (
1977 | File "/ve/lib/python3.8/site-packages/graphql_relay/connection/connection.py", line 3, in <module>
1978 | from graphql.type import (
1979 | File "/ve/lib/python3.8/site-packages/graphql/type/__init__.py", line 8, in <module>
1980 | from .schema import (
1981 | File "/ve/lib/python3.8/site-packages/graphql/type/schema.py", line 17, in <module>
1982 | from .definition import (
1983 | File "/ve/lib/python3.8/site-packages/graphql/type/definition.py", line 57, in <module>
1984 | from ..utilities.value_from_ast_untyped import value_from_ast_untyped
1985 | File "/ve/lib/python3.8/site-packages/graphql/utilities/__init__.py", line 14, in <module>
1986 | from .get_operation_root_type import get_operation_root_type
1987 | File "/ve/lib/python3.8/site-packages/graphql/utilities/get_operation_root_type.py", line 9, in <module>
1988 | from ..type import GraphQLObjectType, GraphQLSchema
1989 | ImportError: cannot import name 'GraphQLObjectType' from partially initialized module 'graphql.type' (most likely due to a circular import) (/ve/lib/python3.8/site-packages/graphql/type/__init__.py)

Project starting without errors.

sjdemartini commented 1 year ago

Can you please try the latest version of graphene-django, and if the error persists, provide detailed steps to reproduce the issue?

jaw9c commented 1 year ago

I think you've got a python circular import in the files you define your schema (perhaps we need a better error message for this). Rather than importing a type, you can use the string path to that type, e.g from app.types import MyType => app.types.MyType