MichalLytek / MichalLytek/type-graphql
Allow deferred types and silent authMode per Authorized decorator
- Dominant language
- TypeScript
- Stars
- 8.1k
- Forks
- 672
- PR merge metrics
- No merged PRs in 30d
Description
**Is your feature request related to a problem? Please describe.**
I am having problems with circular dependency when using a user role enum on Authorized in props (no problem in resolvers). Also I dont want to throw errors when access is denied to a single prop, just return null. But if the decorator is used in a resolver, it is fine to return the errors. The current solution is global by defining the ``authMode: "null"`` in the ``buildSchema``.
**Describe the solution you'd like**
I would like something like this:
```ts
@Authorized(() => [UserType.STAFF, UserType.MANAGER], { silent: true })
@Field({ nullable: true })
someProp: boolean;
```
Contributor guide
Research direction
Start by tracing the Authorized decorator and the buildSchema authMode option, focusing on how authorization differs between fields and resolvers. Determine how deferred role values and a per-decorator silent option should interact with nullable fields, then verify that denied fields return null while resolver denials still produce errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api, authorization
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100