Skip to content

Map pg's uuid to graphene's uuid #203

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
9 changes: 7 additions & 2 deletions graphene_sqlalchemy/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
from sqlalchemy.dialects import postgresql
from sqlalchemy.orm import interfaces, strategies

from graphene import (ID, Boolean, Dynamic, Enum, Field, Float, Int, List,
String)
from graphene import (ID, UUID, Boolean, Dynamic, Enum, Field, Float, Int,
List, String)
from graphene.types.json import JSONString

from .batching import get_batch_resolver
Expand Down Expand Up @@ -260,3 +260,8 @@ def convert_json_to_string(type, column, registry=None):
@convert_sqlalchemy_type.register(JSONType)
def convert_json_type_to_string(type, column, registry=None):
return JSONString


@convert_sqlalchemy_type.register(postgresql.UUID)
def convert_column_to_uuid(type, column, registry=None):
return UUID
2 changes: 1 addition & 1 deletion graphene_sqlalchemy/tests/test_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ class Meta:


def test_should_postgresql_uuid_convert():
assert get_field(postgresql.UUID()).type == graphene.String
assert get_field(postgresql.UUID()).type == graphene.UUID


def test_should_postgresql_enum_convert():
Expand Down