MichalLytek / MichalLytek/type-graphql
Expose decorator types
- Dominant language
- TypeScript
- Stars
- 8.1k
- Forks
- 672
- PR merge metrics
- No merged PRs in 30d
Description
Expose decorator types like `ReturnTypeFuncValue`. This is useful if you want to implement a generic paginated response type. We use an abstract class aka `interface` for `itemsFieldValue`. An abstract doesn't fulfill `ClassType`. `ReturnTypeFuncValue` would allow us to use the same type as the decorator expects.
```ts
export default function PaginatedResponse(
itemsFieldValue: ClassType | String | Number | Boolean,
) {
// `isAbstract` decorator option is mandatory to prevent registering in schema
@ObjectType({ isAbstract: true })
abstract class PaginatedResponseClass {
@Field(type => [itemsFieldValue])
items: TItemsFieldValue[];
@Field(type => Int)
total: number;
@Field()
hasMore: boolean;
}
return PaginatedResponseClass;
}
```
Contributor guide
Assessment
This issue has not been assessed yet.