Improved resolver function decorators

This commit is contained in:
Syrus Akbary 2015-12-03 23:41:28 -08:00
parent 967a9d2d03
commit 28414955a2

View File

@ -63,6 +63,9 @@ class Field(OrderedType):
return NonNull(self.type) return NonNull(self.type)
return self.type return self.type
def decorate_resolver(self, resolver):
return snake_case_args(resolver)
def internal_type(self, schema): def internal_type(self, schema):
resolver = self.resolver resolver = self.resolver
description = self.description description = self.description
@ -85,9 +88,9 @@ class Field(OrderedType):
return my_resolver(instance, args, info) return my_resolver(instance, args, info)
resolver = wrapped_func resolver = wrapped_func
resolver = snake_case_args(resolver)
assert type, 'Internal type for field %s is None' % str(self) assert type, 'Internal type for field %s is None' % str(self)
return GraphQLField(type, args=schema.T(arguments), resolver=resolver, return GraphQLField(type, args=schema.T(arguments),
resolver=self.decorate_resolver(resolver),
description=description,) description=description,)
def __repr__(self): def __repr__(self):