diff --git a/graphene/types/schema.py b/graphene/types/schema.py index 5db3a83e..340eedc3 100644 --- a/graphene/types/schema.py +++ b/graphene/types/schema.py @@ -151,8 +151,7 @@ class TypeMap(dict): self[name] = graphql_type return graphql_type - @staticmethod - def create_scalar(graphene_type): + def create_scalar(self, graphene_type): # We have a mapping to the original GraphQL types # so there are no collisions. _scalars = { @@ -167,7 +166,7 @@ class TypeMap(dict): return GrapheneScalarType( graphene_type=graphene_type, - name=graphene_type._meta.name, + name=self.add_prefix_to_type_name(graphene_type._meta.name), description=graphene_type._meta.description, serialize=getattr(graphene_type, "serialize", None), parse_value=getattr(graphene_type, "parse_value", None), diff --git a/graphene/types/tests/test_schema.py b/graphene/types/tests/test_schema.py index 75084976..3ac0600b 100644 --- a/graphene/types/tests/test_schema.py +++ b/graphene/types/tests/test_schema.py @@ -10,7 +10,7 @@ from ..inputobjecttype import InputObjectType from ..interface import Interface from ..mutation import Mutation from ..objecttype import ObjectType -from ..scalars import Int, String +from ..scalars import Int, String, Scalar from ..schema import Schema from ..union import Union @@ -19,6 +19,10 @@ class MyInputObjectType(InputObjectType): field = String() +class MyScalar(Scalar): + ... + + class MyEnum(Enum): FOO = "foo" BAR = "bar" @@ -35,6 +39,7 @@ class MyBarType(ObjectType): class MyFooType(ObjectType): field = String() + my_scalar = MyScalar() my_enum = MyEnum() @@ -135,9 +140,12 @@ def test_schema_str(): type MyFooType { field: String + myScalar: MyScalar myEnum: MyEnum } + scalar MyScalar + enum MyEnum { FOO BAR @@ -201,9 +209,12 @@ def test_schema_type_name_prefix_camelcase(): type MyPrefixMyFooType { field: String + myScalar: MyPrefixMyScalar myEnum: MyPrefixMyEnum } + scalar MyPrefixMyScalar + enum MyPrefixMyEnum { FOO BAR @@ -265,9 +276,12 @@ def test_schema_type_name_prefix_camelcase_disabled(): type MyPrefixMyFooType { field: String + my_scalar: MyPrefixMyScalar my_enum: MyPrefixMyEnum } + scalar MyPrefixMyScalar + enum MyPrefixMyEnum { FOO BAR