graphql-python / graphene-sqlalchemy

Graphene SQLAlchemy integration
http://docs.graphene-python.org/projects/sqlalchemy/en/latest/
MIT License
974 stars 225 forks source link

fix singledispatch inheritance #377

Closed erikwrede closed 1 year ago

erikwrede commented 1 year ago
codecov[bot] commented 1 year ago

Codecov Report

Base: 96.36% // Head: 96.39% // Increases project coverage by +0.03% :tada:

Coverage data is based on head (1595d4e) compared to base (d3a4320). Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #377 +/- ## ========================================== + Coverage 96.36% 96.39% +0.03% ========================================== Files 9 9 Lines 908 916 +8 ========================================== + Hits 875 883 +8 Misses 33 33 ``` | [Impacted Files](https://codecov.io/gh/graphql-python/graphene-sqlalchemy/pull/377?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=graphql-python) | Coverage Δ | | |---|---|---| | [graphene\_sqlalchemy/converter.py](https://codecov.io/gh/graphql-python/graphene-sqlalchemy/pull/377?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=graphql-python#diff-Z3JhcGhlbmVfc3FsYWxjaGVteS9jb252ZXJ0ZXIucHk=) | `95.83% <100.00%> (+0.01%)` | :arrow_up: | | [graphene\_sqlalchemy/utils.py](https://codecov.io/gh/graphql-python/graphene-sqlalchemy/pull/377?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=graphql-python#diff-Z3JhcGhlbmVfc3FsYWxjaGVteS91dGlscy5weQ==) | `96.09% <100.00%> (+0.22%)` | :arrow_up: | Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=graphql-python). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=graphql-python)

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

palisadoes commented 1 year ago

I removed the custom converters for BigInt and updated this class we discussed in slack/email with :

class Cabinet(SQLAlchemyObjectType, CabinetAttribute):
    """Cabinet node."""

    class Meta:
        """Define the metadata."""

        model = CabinetModel
        interfaces = (graphene.relay.Node,)

    id_ = ORMField(type_=graphene.BigInt)

Here are the errors:

Jan 26 19:53:57 my.server.name boss-app[3402721]: Traceback (most recent call last):
Jan 26 19:53:57 my.server.name boss-app[3402721]:   File "/path/to/code/sbin/server/boss-app", line 34, in <module>
Jan 26 19:53:57 my.server.name boss-app[3402721]:     from slurpy.server.api import API
Jan 26 19:53:57 my.server.name boss-app[3402721]:   File "/data/path/to/code/slurpy/server/api/__init__.py", line 39, in <module>
Jan 26 19:53:57 my.server.name boss-app[3402721]:     from slurpy.server.api.routes.graphql import API_GRAPHQL
Jan 26 19:53:57 my.server.name boss-app[3402721]:   File "/data/path/to/code/slurpy/server/api/routes/graphql.py", line 8, in <module>
Jan 26 19:53:57 my.server.name boss-app[3402721]:     from slurpy.server.db.schemas import SCHEMA
Jan 26 19:53:57 my.server.name boss-app[3402721]:   File "/data/path/to/code/slurpy/server/db/schemas.py", line 113, in <module>
Jan 26 19:53:57 my.server.name boss-app[3402721]:     class Cabinet(SQLAlchemyObjectType, CabinetAttribute):
Jan 26 19:53:57 my.server.name boss-app[3402721]:   File "/usr/local/lib/python3.8/dist-packages/graphene/types/objecttype.py", line 29, in __new__
Jan 26 19:53:57 my.server.name boss-app[3402721]:     base_cls = super().__new__(
Jan 26 19:53:57 my.server.name boss-app[3402721]:   File "/usr/local/lib/python3.8/dist-packages/graphene/utils/subclass_with_meta.py", line 46, in __init_subclass__
Jan 26 19:53:57 my.server.name boss-app[3402721]:     super_class.__init_subclass_with_meta__(**options)
Jan 26 19:53:57 my.server.name boss-app[3402721]:   File "/usr/local/lib/python3.8/dist-packages/graphene_sqlalchemy/types.py", line 593, in __init_subclass_with_meta__
Jan 26 19:53:57 my.server.name boss-app[3402721]:     super(SQLAlchemyObjectType, cls).__init_subclass_with_meta__(
Jan 26 19:53:57 my.server.name boss-app[3402721]:   File "/usr/local/lib/python3.8/dist-packages/graphene_sqlalchemy/types.py", line 436, in __init_subclass_with_meta__
Jan 26 19:53:57 my.server.name boss-app[3402721]:     fields, filters = construct_fields_and_filters(
Jan 26 19:53:57 my.server.name boss-app[3402721]:   File "/usr/local/lib/python3.8/dist-packages/graphene_sqlalchemy/types.py", line 337, in construct_fields_and_filters
Jan 26 19:53:57 my.server.name boss-app[3402721]:     field = convert_sqlalchemy_column(
Jan 26 19:53:57 my.server.name boss-app[3402721]:   File "/usr/local/lib/python3.8/dist-packages/graphene_sqlalchemy/converter.py", line 273, in convert_sqlalchemy_column
Jan 26 19:53:57 my.server.name boss-app[3402721]:     convert_sqlalchemy_type(column_type, column=column, registry=registry),
Jan 26 19:53:57 my.server.name boss-app[3402721]:   File "/usr/local/lib/python3.8/dist-packages/graphene_sqlalchemy/utils.py", line 206, in __call__
Jan 26 19:53:57 my.server.name boss-app[3402721]:     return self.default(*args, **kwargs)
Jan 26 19:53:57 my.server.name boss-app[3402721]:   File "/usr/local/lib/python3.8/dist-packages/graphene_sqlalchemy/converter.py", line 295, in convert_sqlalchemy_type
Jan 26 19:53:57 my.server.name boss-app[3402721]:     raise TypeError(
Jan 26 19:53:57 my.server.name boss-app[3402721]: TypeError: Don't know how to convert the SQLAlchemy field sy_cabinets.id (<class 'sqlalchemy.sql.schema.Column'>, <class 'sqlalchemy.dialects.mysql.types.BIGINT'>). Please add a type converter or set the type manually using ORMField(type_=your_type)
Jan 26 19:53:57 my.server.name systemd[1]: boss-app.service: Control process exited, code=exited, status=1/FAILURE
palisadoes commented 1 year ago

After following your advice on slack it loads in my app without error.