-
Notifications
You must be signed in to change notification settings - Fork 766
Closed
Labels
Description
I'm able to use DjangoModelFormMutation but am curious of how to limit mutation access along with query access similar to https://docs.graphene-python.org/projects/django/en/latest/authorization/
Currently I simply have a class inheriting from DjangoModelFormMutation. I want to be able to restrict access to the owners of the Model Objects, and possibly do other filter on based on user for querying.
This is currently how I am handling it and fine to keep doing this if this is the best practice.
@classmethod
def mutate_and_get_payload(cls, root, info, **input):
user = info.context.user
# TODO add a check to see if user has access
if not user.is_authenticated:
raise GraphQLError("Unauthorized")
return super().mutate_and_get_payload(root, info, **input)
Thanks for the help.
juanjcardona13, scottbarnes, tolliver73 and heckad