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

Permissions with graphene-django-extras

Open karlosss opened this issue 5 years ago • 5 comments

Hi everyone,

I would like to implement an easy permissions system. With original graphene-django, it was quite straightforward. It was sufficient to make a similar method for each field on an object:

def resolve_field(self):
    if not has_permission():
        raise PermissionError("Access Denied!")
    return self.field

Here it is a bit more difficult, since DjangoObjectListField just bypasses these methods. The docs say that they are not needed, but even if they are present, they are just simply ignored.

Do you have any advice how to implement permissions here? Either how to force DjangoObjectListField not to ignore resolve_field method, or suggest a completely different approach.

Thanks!

karlosss avatar Aug 08 '19 14:08 karlosss

Pinging as I'm interested on this as well, since I want to restrict the queries our users can make

Rydra avatar Nov 18 '19 13:11 Rydra

Hi, I tried to make django model mutations for django-graphene more accessible and customizable, in similar way to django rest framework, I published it here: https://github.com/topletal/django-model-mutations, any feedback is welcomed, also please keep in mind its just initial release and although there are decent tests, there might be some edge cases not tested yet - graphene does a lot of magic actually behind the curtains.

topletal avatar Nov 18 '19 15:11 topletal

I have a similar problem right now, but with querysets. The way graphene-django-extras handles a lot of internal logic looks odd to me. Is there any official guide for that, in addition to the small README?

shockflash avatar Nov 23 '19 22:11 shockflash

I wanted to check permissions using get_queryset. It works fine with regular graphene using DjangoListField, but not with graphene-django-extras. Even though the class is named DjangoFilterPaginateListField it doesn't inherit from DjangoListField and so it doesn't call get_queryset . I've search for other functions I could hook to to check permissions, but it looks like there aren't any.

sbernier1 avatar Mar 15 '20 00:03 sbernier1

@sbernier1 you want to overload list_resolver

jstacoder avatar Jun 26 '20 05:06 jstacoder