graphene-django icon indicating copy to clipboard operation
graphene-django copied to clipboard

Possible regression in resolving types on filtered connections

Open winged opened this issue 2 years ago • 1 comments

Since updating to graphene-django v3.0.0, I'm getting a TypeError, originating from graphene_django.filter.utils.get_filtering_args_from_filterset() (registry = type._meta.registry):

TypeError: Form fields cannot be resolved. 'InterfaceOptions' object has no attribute 'registry'

The thing that's special about this is that the type referenced by the affected connection is in fact an interface, not a direct DjangoObjectType.

The regression came in between v3.0.0b7 and v3.0.0b8. I tried git bisecting it, but due to unrelated (?) errors such as import issues within graphene-django, I was unable to pinpoint the exact commit responsible.

Interestingly, the affected line was there long before, but somehow didn't trigger in b7.

Reproduction: Due to the complexity of our code base, I was not (yet) able to extract a simple reproducer for this. Depending on what's coming up in the discussion of this issue, I'll try to put in the work to get it going.

Currently, we were able to workaround it by providing a detailled Meta object, which feels very very wrong:


class Question(Node, graphene.Interface):
    # ...
    class Meta:
        model = models.Question
        fields = "__all__"
        connection_class = graphene.Connection

        class _meta:
            fields = []
            interfaces = (relay.Node,)
            registry = get_global_registry() # this is where get_filtering_args_from_filterset() looks for it
            # I know this is wrong, just a proof of concept to get a workaround going
            @staticmethod
            def freeze():
                pass

The full stack trace is not very useful, as the exception gets re-packaged and rethrown a couple of times.

winged avatar Sep 29 '22 12:09 winged

Good catch! Was anyone able to create a compact reproduction for this so far?

erikwrede avatar Oct 23 '22 18:10 erikwrede