strawberry-django-plus icon indicating copy to clipboard operation
strawberry-django-plus copied to clipboard

Non-obvious moments when overloading the Connection

Open iamcrookedman opened this issue 1 year ago • 1 comments

Hello I tried to define a custom Connection class to extend it with the data I need. For this, the Node class was also redefined, and I encountered non-obvious behavior when defining the resolve_connection method

def _has_own_node_resolver(cls, name: str) -> bool:
    resolver = getattr(cls, name, None)
    if resolver is None:
        return False

    if id(resolver.__func__) == id(getattr(Node, name).__func__):
        return False

    return True

It turns out that the method described in the Node class is replaced by default with another one, and when defining a custom class, it is impossible to call super of the parent class In other words, when defining a class and at runtime, we have different resolvers What is the reason for this behaviour? Wouldn't it be better to immediately set the necessary behavior in the Node class?

iamcrookedman avatar Dec 28 '22 11:12 iamcrookedman