diff --git a/graphene/core/types/base.py b/graphene/core/types/base.py index 8cfa603f..35f93267 100644 --- a/graphene/core/types/base.py +++ b/graphene/core/types/base.py @@ -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): diff --git a/graphene/core/types/scalars.py b/graphene/core/types/scalars.py index d0d315b4..a87ddea2 100644 --- a/graphene/core/types/scalars.py +++ b/graphene/core/types/scalars.py @@ -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