Strawberry (python) directives for role-based authentication

102 views Asked by At

My task is as follows: there is a GraphQL schema in which both queries and mutations are present. An http request to GraphQL comes from the frontend, I get a token from the header, then using my method I can get data about the user, namely which role belongs to him (for simplicity there will be 2 roles - admin and user). I need to make certain mutations and queries work either for everyone (both admins and users), or only for admins. I know that you can use strawberry.permissions, but this is not exactly what you need, because they do not appear in any way in the GraphQL schema, that is, it will not be visible on the frontend that the admin role is needed for certain actions, for example.

I tried to use decorator, but it doesn't work :(

0

There are 0 answers