graphql-python / graphql-python/graphene-django

Possible regression in resolving types on filtered connections

Open
#1,357 1 comment 2 reactions 0 assignees View on GitHub
🐛bug 👀 more info needed
Dominant language
Python
Stars
4.4k
Forks
760
PR merge metrics
No merged PRs in 30d

Description

Since updating to `graphene-django` v3.0.0, I'm getting a `TypeError`, originating from [graphene_django.filter.utils.get_filtering_args_from_filterset()](https://github.com/graphql-python/graphene-django/blob/main/graphene_django/filter/utils.py#L34) (`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 bisect`ing 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:
```python

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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.