Closed iorlandini closed 3 years ago
@iorlandini it seems that the tests are failing for Django 2.2 in travis. I run the tests locally on this PR branch and they worked just fine. Do you know why the tests are failing?
Hi @tfoxy! Yes, I know. It's because of the test itself. I used the django.contrib.auth.models.User
model to illustrate a point and it seems to not exist in version 2.2. I'll replace it tomorrow with a dummy model for the test.
@tfoxy I did not fix it because of the change proposed by @maxpeterson in https://github.com/tfoxy/graphene-django-optimizer/pull/50. And I will close this PR if this one goes through.
The
OptimizedDjangoObjectType.get_node
method breaks theDjangoObjectType.get_node
method default behaviour.In the first one, the query set is the model manager:
In the second one, the base and original one, the query set is obtained from the
ObjectType.get_queryset
:This is very important and that's why I created a real use case test based on items owned by a logged-in user.
The fix is very simple, the method has to use the
get_queryset
method based on the model manager instead of the model manager directly:And I hope the test itself explains why is so important.
On the other hand, if we set a
get_queryset
method that automatically affects the scope of the returned elements by querying a specific type, we also expect the same scope to be affected when getting a node from its global ID.