Skip to content

Commit 752cd77

Browse files
committed
Improved field resolving if instance is not wrapped
1 parent 3dd6d00 commit 752cd77

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

graphene/core/fields.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,12 @@ def resolve(self, instance, args, info):
5555
if resolve_fn:
5656
return resolve_fn(instance, args, info)
5757
else:
58-
return instance.get_field(self.field_name)
58+
if isinstance(instance, BaseObjectType):
59+
return instance.get_field(self.field_name)
60+
if hasattr(instance, self.field_name):
61+
return getattr(instance, self.field_name)
62+
elif hasattr(instance, self.name):
63+
return getattr(instance, self.name)
5964

6065
@memoize
6166
def get_resolve_fn(self):
@@ -74,6 +79,8 @@ def custom_resolve_fn(instance, args, info):
7479

7580
def get_object_type(self, schema):
7681
field_type = self.field_type
82+
if inspect.isfunction(field_type):
83+
field_type = field_type(self)
7784
_is_class = inspect.isclass(field_type)
7885
if isinstance(field_type, Field):
7986
return field_type.get_object_type(schema)

0 commit comments

Comments
 (0)