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

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

Open
yankeexe opened this issue Jul 25, 2023 · 2 comments
Labels

Comments

@yankeexe
Copy link

yankeexe commented Jul 25, 2023

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)

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

@sjdemartini
Copy link
Collaborator

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

@jaw9c
Copy link
Collaborator

jaw9c commented Jul 25, 2023

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

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

No branches or pull requests

3 participants