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

Add auto_context_queryset_filter Meta field

Open mbuvarp opened this issue 3 years ago • 1 comments

Would be nice having a field to restrict the available queryset for update and patch mutations based on context values. For example, say you have the field organization in the context. You could do something like this:

class PatchUserMutation(DjangoPatchMutation):
  class Meta:
    model = User
    auto_context_queryset_filter = {
      "organization": "organization"
    }

A user would then only be able to patch users in the same organization as them.

mbuvarp avatar Feb 09 '21 18:02 mbuvarp

After closer consideration, I am unsure whether or not this should actually be a part of the library. At some point, we'll end up putting our (this library's) hands in too much business logic.

tOgg1 avatar Mar 13 '22 10:03 tOgg1