graphql-python / graphene-sqlalchemy

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

Can a registered converter be shadowed to use a type other than a `graphene` type? #308

Closed this-vidor closed 1 year ago

this-vidor commented 3 years ago

For example, suppose a developer did not want sqlalchemy.dialects.postgres.HSTORE to be converted to graphene.types.json.JSONString. Is there a correct way to accomplish that?

erikwrede commented 1 year ago

The solution is to override the default type converter:

@convert_sqlalchemy_type.register(postgresql.HSTORE)
def convert_json_to_string(type, column, registry=None):
    return your_graphene_scalar

This needs to be called before your SQLAlchemyObjectTypes are initialized.

github-actions[bot] commented 1 year ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related topics referencing this issue.