Make UUID compatible (Fixed issue #936) (#937)

* Make UUID compatible

* Fix typo

* black code formatting
This commit is contained in:
Eran Kampf 2019-04-08 14:06:32 -07:00 committed by GitHub
parent bcbb66c025
commit d0cfee5641
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,5 @@
from __future__ import absolute_import from __future__ import absolute_import
import six
from uuid import UUID as _UUID from uuid import UUID as _UUID
from graphql.language import ast from graphql.language import ast
@ -12,8 +12,9 @@ class UUID(Scalar):
@staticmethod @staticmethod
def serialize(uuid): def serialize(uuid):
if isinstance(uuid, str): if isinstance(uuid, six.string_types):
uuid = _UUID(uuid) uuid = _UUID(uuid)
assert isinstance(uuid, _UUID), "Expected UUID instance, received {}".format( assert isinstance(uuid, _UUID), "Expected UUID instance, received {}".format(
uuid uuid
) )