Oleg Korkeshko
Oleg Korkeshko

Reputation: 43

How to put permissions on input fields in strawberry GraphQL?

I found a way to set permissions on starwberry type fields like this:

@strawberry.type
class SomeModel:
    id: strawberry.ID
    login: Optional[str] = strawberry.field(permission_classes=[Permission])

But when I try to put the same logic on input fields, to make them immutable for certain users like this:

@strawberry.input
class SomeModel:
    login: str = strawberry.field(permission_classes=[Permission])

It doesn't work, is there a way to make what I want with standard strawberry functionality or may be some other tool?

I read the official strawberry documentation on permissions, but didn't find any info on setting permissions on separate input fields. I also searched docs of a couple packages that extends functionality of strawberry, but didn't find any useful info

Upvotes: 3

Views: 699

Answers (1)

patrick
patrick

Reputation: 6840

Strawberry doesn't support permissions in input fields, I don't think we considered that use case!

Will you be willing to open an issue describing what you need? Hopefully it's not too difficult to implement 😊

Upvotes: 1

Related Questions