graphene-django icon indicating copy to clipboard operation
graphene-django copied to clipboard

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

Open yankeexe opened this issue 1 year ago • 2 comments

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

  • What is the current behavior? When running project with graphene-django installed I get the following error:
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)

  • If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via a github repo, https://repl.it or similar (you can use this template as a starting point: https://repl.it/@jkimbo/Graphene-Django-Example).

  • What is the expected behavior?

Project starting without errors.

  • Please tell us about your environment:

    • Version:

      graphene: 3.0b7
      graphene-django: 3.0.0b7
      graphql-core: 3.1.5
      graphql-relay: 3.1.0
      
    • Platform: Linux

yankeexe avatar Jul 25 '23 07:07 yankeexe

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

sjdemartini avatar Jul 25 '23 14:07 sjdemartini

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

jaw9c avatar Jul 25 '23 21:07 jaw9c