Skip to content

Handle types.JSON and types.Variant #277

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

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions graphene_sqlalchemy/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
9 changes: 9 additions & 0 deletions graphene_sqlalchemy/tests/test_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down Expand Up @@ -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

Expand Down