Improved ScalarTypes code

This commit is contained in:
Syrus Akbary 2015-12-06 15:53:56 -08:00
parent 37a454b831
commit 2724025a5b
2 changed files with 17 additions and 13 deletions

View File

@ -5,9 +5,8 @@ import six
class InstanceType(object):
@classmethod
def internal_type(cls, schema):
return getattr(cls, 'T', None)
def internal_type(self, schema):
raise NotImplementedError("internal_type for type {} is not implemented".format(self.__class__.__name__))
class MountType(InstanceType):

View File

@ -4,21 +4,26 @@ from graphql.core.type import (GraphQLBoolean, GraphQLFloat, GraphQLID,
from .base import MountedType
class String(MountedType):
T = GraphQLString
class ScalarType(MountedType):
def internal_type(self, schema):
return self._internal_type
class Int(MountedType):
T = GraphQLInt
class String(ScalarType):
_internal_type = GraphQLString
class Boolean(MountedType):
T = GraphQLBoolean
class Int(ScalarType):
_internal_type = GraphQLInt
class ID(MountedType):
T = GraphQLID
class Boolean(ScalarType):
_internal_type = GraphQLBoolean
class Float(MountedType):
T = GraphQLFloat
class ID(ScalarType):
_internal_type = GraphQLID
class Float(ScalarType):
_internal_type = GraphQLFloat