mirror of
https://github.com/graphql-python/graphene.git
synced 2024-11-14 05:36:45 +03:00
Improved ScalarTypes code
This commit is contained in:
parent
37a454b831
commit
2724025a5b
|
@ -5,9 +5,8 @@ import six
|
||||||
|
|
||||||
class InstanceType(object):
|
class InstanceType(object):
|
||||||
|
|
||||||
@classmethod
|
def internal_type(self, schema):
|
||||||
def internal_type(cls, schema):
|
raise NotImplementedError("internal_type for type {} is not implemented".format(self.__class__.__name__))
|
||||||
return getattr(cls, 'T', None)
|
|
||||||
|
|
||||||
|
|
||||||
class MountType(InstanceType):
|
class MountType(InstanceType):
|
||||||
|
|
|
@ -4,21 +4,26 @@ from graphql.core.type import (GraphQLBoolean, GraphQLFloat, GraphQLID,
|
||||||
from .base import MountedType
|
from .base import MountedType
|
||||||
|
|
||||||
|
|
||||||
class String(MountedType):
|
class ScalarType(MountedType):
|
||||||
T = GraphQLString
|
def internal_type(self, schema):
|
||||||
|
return self._internal_type
|
||||||
|
|
||||||
|
|
||||||
class Int(MountedType):
|
class String(ScalarType):
|
||||||
T = GraphQLInt
|
_internal_type = GraphQLString
|
||||||
|
|
||||||
|
|
||||||
class Boolean(MountedType):
|
class Int(ScalarType):
|
||||||
T = GraphQLBoolean
|
_internal_type = GraphQLInt
|
||||||
|
|
||||||
|
|
||||||
class ID(MountedType):
|
class Boolean(ScalarType):
|
||||||
T = GraphQLID
|
_internal_type = GraphQLBoolean
|
||||||
|
|
||||||
|
|
||||||
class Float(MountedType):
|
class ID(ScalarType):
|
||||||
T = GraphQLFloat
|
_internal_type = GraphQLID
|
||||||
|
|
||||||
|
|
||||||
|
class Float(ScalarType):
|
||||||
|
_internal_type = GraphQLFloat
|
||||||
|
|
Loading…
Reference in New Issue
Block a user