Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

How to handle permissions per Object #1182

Answered by HaukLee
sgaseretto asked this question in Q&A
Discussion options

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

You must be logged in to vote

Replies: 8 comments

Comment options

It has been discussed previously
#79

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

You must be logged in to vote
0 replies
Comment options

@annshress how about queries? This only addresses mutation

You must be logged in to vote
0 replies
Comment options

@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
You must be logged in to vote
0 replies
Comment options

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

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

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.

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by zbyte64
Comment options

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

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
Converted from issue

This discussion was converted from issue #396 on April 14, 2021 20:20.

AltStyle によって変換されたページ (->オリジナル) /