Open tcleonard opened 3 years ago
Submitted 2 PRs:
hello, I am facing the same issue, how is this work going?
This is blocking on me, I need to review the alternative PR to see if it's a better solution to the problem. Haven't had time to take a look just yet. For the record I have been using my PR for quite some time and other than the performance overhead it does the job.
In the converters the way the reverse relation of a foreign key is dealt with differently from the forward relationship.
Indeed you can see in the
ManyToOneRel
conversionconvert_field_to_list_or_connection()
we convert the field to either aDjangoConnectionField
or aDjangoListField
(depending on if it uses relay or not). Both of those make sure that the resolution of the field is going through those custom classes resolvers. This is important as those implement some hooks to resolve the queryset in a custom way (or to give a custom queryset manager).On the other hand, the
ForeignKey
conversionconvert_field_to_djangomodel()
implements a simplegraphene.Field
hence bypassing any potential custom queryset filtering.This is notably a problem as those resolver hooks are typically used to implement authorization... and this behavior means that we enforce it only in one direction, resulting in permissions leaks.
I have a quick fix for this problem but I think it degrades performances by doing an additional query to the database:
I am going to submit as a PR with some unit tests but I would love to get some feedback as it seems pretty hacky...