-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Permissions per object like in DRF and django-guardian #10
Comments
Hi, sorry for the late reply. Generalizing, if you have model Project and user groups per project - you could do something like that
I didn't test it thoroughly with django-guardian, but creating groups and checking if user is in specific group should be easy enough. If further integration with guardian would be usefull for more developers, i'll think about adding that, just give some feedback. |
@redzej the problem is here: class AllowProjectOwner:
@staticmethod
def has_node_permission(info, id):
# check if user belongs to specific group or has required role
return info.context.user == Project.objects.get(pk=id).owner That's one query, and after this method returns True there's going to be another DB trip to retrieve the same object. |
@adamziel yes, i'm aware of that, this was just a temporary solution. Recently i got some spare time, so i`m going to submit 2 PR's regarding that. |
Django will cache the One improvement could be to specifically only get the owner from the database: return info.context.user == Project.objects.only('owner').get(pk=id).owner |
Like, for example, you implement a project management software where each user can participate in different projects and have a different role in each project, like SCRUM Master, Product Owner, and Developer. One user can be in different projects and have a different role for each project that will allow him to do different kinds of queries and mutations in each project. Is it possible to achieve something like this with graphene-permissions and how?
The text was updated successfully, but these errors were encountered: