diff --git a/graphene_sqlalchemy/converter.py b/graphene_sqlalchemy/converter.py index f4b805e2..b632c2df 100644 --- a/graphene_sqlalchemy/converter.py +++ b/graphene_sqlalchemy/converter.py @@ -249,5 +249,11 @@ def convert_json_to_string(type, column, registry=None): @convert_sqlalchemy_type.register(JSONType) +@convert_sqlalchemy_type.register(types.JSON) def convert_json_type_to_string(type, column, registry=None): return JSONString + + +@convert_sqlalchemy_type.register(types.Variant) +def convert_variant_to_impl_type(type, column, registry=None): + return convert_sqlalchemy_type(type.impl, column, registry=registry) diff --git a/graphene_sqlalchemy/tests/test_converter.py b/graphene_sqlalchemy/tests/test_converter.py index f0fc1802..617c3750 100644 --- a/graphene_sqlalchemy/tests/test_converter.py +++ b/graphene_sqlalchemy/tests/test_converter.py @@ -188,6 +188,7 @@ def test_should_scalar_list_convert_list(): def test_should_jsontype_convert_jsonstring(): assert get_field(JSONType()).type == JSONString + assert get_field(types.JSON()).type == JSONString def test_should_manytomany_convert_connectionorlist(): @@ -286,6 +287,14 @@ class Meta: assert graphene_type.type == A +def test_should_variant_int_convert_int(): + assert get_field(types.Variant(types.Integer(), {})).type == graphene.Int + + +def test_should_variant_string_convert_string(): + assert get_field(types.Variant(types.String(), {})).type == graphene.String + + def test_should_postgresql_uuid_convert(): assert get_field(postgresql.UUID()).type == graphene.String