From d3305f6056d7de38e736ab26f2f36b9ea3b8491c Mon Sep 17 00:00:00 2001 From: Markus Padourek Date: Fri, 21 Oct 2016 09:34:06 +0100 Subject: [PATCH] Make scalar get_type an instance method. Given the current way of how Scalars are mostly being created in the schema, e.g. `graphene.Boolean(description='Some boolean')` and then how they get 'magically' turned into a `Field` using `self.get_type()` it makes sense to make this an Instance method rather than a classmethod. This allows e.g. to set attributes on the instance that will always be accessible, as they are being returned by `get_type`. --- graphene/types/scalars.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/graphene/types/scalars.py b/graphene/types/scalars.py index d6060d33..a9b5b7af 100644 --- a/graphene/types/scalars.py +++ b/graphene/types/scalars.py @@ -41,9 +41,8 @@ class Scalar(six.with_metaclass(ScalarTypeMeta, UnmountedType)): parse_value = None parse_literal = None - @classmethod - def get_type(cls): - return cls + def get_type(self): + return self # As per the GraphQL Spec, Integers are only treated as valid when a valid # 32-bit signed integer, providing the broadest support across platforms.