MichalLytek / MichalLytek/typegraphql-prisma
Authorization annotations
- Dominant language
- TypeScript
- Stars
- 918
- Forks
- 130
- PR merge metrics
- No merged PRs in 30d
Description
**Is your feature request related to a problem? Please describe.**
I would like to generate resolvers with `@Authorized` decorators so generated API is protected by unauthorized access.
**Describe the solution you'd like**
I would like to have annotaions that add `@Authorized` decorator to resolvers. For example:
```
/// @TypeGraphQL.Authorized(create:'admin,editor', read:null, update:'admin,editor', delete:'admin')
model Post {
/* ... */
}
```
Given example should result in:
* create resolver accepts `admin` and `editor` role
* read resolver accepts all users, even unauthorized
* update resolve accepts `admin` and `editor` role
* delete accepts only `admin` role.
**Describe alternatives you've considered**
* using 3rd party library to add authorization for resolvers as middleware.
* adding `@Authorized` decorator manually to generated resolvers. All of them are lost after regenerating the code, so it's the worst solution.
Contributor guide
No contributing guide indexed for this repository
Research direction
The issue names no files, tests, or entry points. Start by locating the generator code that emits CRUD resolvers and reviewing how TypeGraphQL authorization decorators are represented; done means schema annotations can apply the requested roles independently to create, read, update, and delete resolvers without being lost on regeneration.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql, typescript
- Domain
- api, authorization
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100