graphql-python / graphene

GraphQL framework for Python

Home Page:http://graphene-python.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Exception: NonNull could not have a mounted String() as inner type. Try with NonNull(String).

balak378 opened this issue · comments

I'm encountering an issue when upgrading the graphene and graphene-sqlalchemy library versions. The issue arises in the context of defining a GraphQL type.

Error Traceback:
File "/path/to/your/file.py", line X, in <module> class GenericEntity(SQLAlchemyObjectType): File "/path/to/graphene/utils/subclass_with_meta.py", line X, in __init_subclass__ super_class.__init_subclass_with_meta__(**options) File "/path/to/graphene_sqlalchemy/types.py", line X, in __init_subclass_with_meta__ construct_fields( File "/path/to/graphene_sqlalchemy/types.py", line X, in construct_fields field = convert_sqlalchemy_column(attr, registry, resolver, **orm_field.kwargs) File "/path/to/graphene_sqlalchemy/converter.py", line X, in convert_sqlalchemy_column return Field( File "/path/to/graphene/types/field.py", line X, in __init__ type = NonNull(type) File "/path/to/graphene/types/structures.py", line X, in __init__ super(NonNull, self).__init__(*args, **kwargs) File "/path/to/graphene/types/structures.py", line X, in __init__ raise Exception( Exception: NonNull could not have a mounted String() as inner type. Try with NonNull(String).
Type definition

class GenericEntity(SQLAlchemyObjectType):
    class Meta:
        model = GenericEntityModel
        interfaces = (relay.Node,)
        exclude_fields = ('ordering_user_id',)

Database Model

Base = declarative_base(metadata=metadata)
class GenericEntity(Base):
    __tablename__ = 'generic_entity'

    id = Column(CHAR(32), default=callable(generate_id), primary_key=True, nullable=False)
    name = Column(String(length=MAX_NAME_LEN), nullable=False)
    address = Column(String(MAX_ADD_LEN), nullable=False)
    organization_id = Column(CHAR(32), ForeignKey('organization.id', ondelete='CASCADE'), nullable=False)
    status = Column(Enum(GenericEntityStatusEnum), nullable=False, default=GenericEntityStatusEnum.available)

    creation_datetime = Column(DateTime, nullable=True)

Dependencies:

Python: ">=3.9, <3.12"
SQLAlchemy: 1.4.51
graphene : ">=2.1.3, v3.0.0"
graphene-sqlalchemy: ">=2.2.2, v3.0.0rc1"

Same code was working earlier with:
graphene: "2.1.2"
graphene-sqlalchemy = "2.0.0"

Sorry!! Release notes wasn't guiding enough to fix these breaking change introduced in later versions!!

Need some help!