Graphene-django: How to handle permissions per Object

Created on 13 Feb 2018  路  8Comments  路  Source: graphql-python/graphene-django

Is there a way to do this like what django-guardian does or DRF with his DjangoModelPermissions?

permissions question

Most helpful comment

I'd refer to the previous body of discussion here. Additionally, should you use django-graphql-jwt, it comes with a built in permissions handler done using decorators.

All 8 comments

It has been discussed previously
https://github.com/graphql-python/graphene-django/issues/79

I have done following as my way to handle permissions currently
https://medium.com/@anish.shrestha/relay-graphene-django-and-permissions-b1b2b96daf20

@annshress how about queries? This only addresses mutation

@hz-equityzen I have not felt the need to handle permissions in queries.

Edit: Okay considering many people need query related permission. You will need to write your own resolver for that.

For example.

def resolve_object(root, info, **kwargs):
    if info.context.user.is_authenticated():
        do something
    else:
        do something else

Actually, In the project I'm working on I need to handle permissions in queries

I'd refer to the previous body of discussion here. Additionally, should you use django-graphql-jwt, it comes with a built in permissions handler done using decorators.

This is exactly what I was looking for, thanks a lot!

Was this page helpful?
0 / 5 - 0 ratings