Skip to content

Commit 2724025

Browse files
committed
Improved ScalarTypes code
1 parent 37a454b commit 2724025

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

graphene/core/types/base.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55

66
class InstanceType(object):
77

8-
@classmethod
9-
def internal_type(cls, schema):
10-
return getattr(cls, 'T', None)
8+
def internal_type(self, schema):
9+
raise NotImplementedError("internal_type for type {} is not implemented".format(self.__class__.__name__))
1110

1211

1312
class MountType(InstanceType):

graphene/core/types/scalars.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,26 @@
44
from .base import MountedType
55

66

7-
class String(MountedType):
8-
T = GraphQLString
7+
class ScalarType(MountedType):
8+
def internal_type(self, schema):
9+
return self._internal_type
910

1011

11-
class Int(MountedType):
12-
T = GraphQLInt
12+
class String(ScalarType):
13+
_internal_type = GraphQLString
1314

1415

15-
class Boolean(MountedType):
16-
T = GraphQLBoolean
16+
class Int(ScalarType):
17+
_internal_type = GraphQLInt
1718

1819

19-
class ID(MountedType):
20-
T = GraphQLID
20+
class Boolean(ScalarType):
21+
_internal_type = GraphQLBoolean
2122

2223

23-
class Float(MountedType):
24-
T = GraphQLFloat
24+
class ID(ScalarType):
25+
_internal_type = GraphQLID
26+
27+
28+
class Float(ScalarType):
29+
_internal_type = GraphQLFloat

0 commit comments

Comments
 (0)