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

fix singledispatch inheritance #377

Merged

Conversation

erikwrede
Copy link
Member

  • fix: Make ORMField(type_) work in case there is no registered converter
  • revert/feat!: Type Converters support subtypes again. this feature adjusts the conversion system to use the MRO of a supplied class

@codecov
Copy link

codecov bot commented Jan 24, 2023

Codecov Report

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

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
@@            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 Coverage Δ
graphene_sqlalchemy/converter.py 95.83% <100.00%> (+0.01%) ⬆️
graphene_sqlalchemy/utils.py 96.09% <100.00%> (+0.22%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

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

@palisadoes
Copy link
Collaborator

palisadoes commented Jan 26, 2023

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
Copy link
Collaborator

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

@erikwrede erikwrede merged commit 1708fcf into graphql-python:master Jan 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants