Simplified unused code

This commit is contained in:
Syrus Akbary 2015-10-03 03:59:24 -07:00
parent 855cee2f34
commit a1c7d3e3de
2 changed files with 1 additions and 14 deletions

View File

@ -36,12 +36,6 @@ class Field(object):
self.field_type.contribute_to_class(cls, name)
cls._meta.add_field(self)
def resolver(self, instance, args, info):
if self.object_type.can_resolve(self.field_name, instance, args, info):
return self.resolve(instance, args, info)
else:
return None
def resolve(self, instance, args, info):
if self.resolve_fn:
resolve_fn = self.resolve_fn
@ -106,7 +100,7 @@ class Field(object):
internal_type,
description=self.description,
args=self.args,
resolver=self.resolver,
resolver=self.resolve,
)
def __str__(self):

View File

@ -121,19 +121,12 @@ class BaseObjectType(object):
return self.instance.__eq__(other)
def resolve(self, field_name, args, info):
if field_name not in self._meta.fields_map.keys():
raise Exception('Field %s not found in model %s' % (field_name, self._meta.type_name))
custom_resolve_fn = 'resolve_%s' % field_name
if hasattr(self, custom_resolve_fn):
resolve_fn = getattr(self, custom_resolve_fn)
return resolve_fn(args, info)
return self.get_field(field_name)
@classmethod
def can_resolve(cls, field_name, instance, args, info):
# Useful for manage permissions in fields
return True
@classmethod
def resolve_type(cls, schema, instance, *_):
return instance.internal_type(schema)