MichalLytek / MichalLytek/type-graphql

Expose decorator types

Open
#954 2 comments 1 reaction 1 assignee Claimed by @MichalLytek View on GitHub
Community :family_man_girl: Enhancement :new:
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.