Skip to content

Commit 2262ea2

Browse files
committed
Expand to capture all graphql type decorators implicitly
1 parent 5f04c84 commit 2262ea2

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/common/resource.dto.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ export class EnhancedResource<T extends ResourceShape<any>> {
194194
const props = this.type.Props;
195195
if (!props) {
196196
throw new Error(
197-
`${this.name} has not been decorated with @RegisterResource`,
197+
`${this.name} has no props declared. Decorate with @RegisterResource or a GraphQL type decorator.`,
198198
);
199199
}
200200
return new Set<keyof T['prototype'] & string>(props);
@@ -205,7 +205,7 @@ export class EnhancedResource<T extends ResourceShape<any>> {
205205
const props = this.type.SecuredProps;
206206
if (!props) {
207207
throw new Error(
208-
`${this.name} has not been decorated with @RegisterResource`,
208+
`${this.name} has no props declared. Decorate with @RegisterResource or a GraphQL type decorator.`,
209209
);
210210
}
211211
return new Set<SecuredResourceKey<T, false>>(props as any);

src/core/resources/plugin/resources.visitor.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,13 @@ export class ResourceVisitor {
3434
(ts.canHaveDecorators(node) && ts.getDecorators(node)) || [];
3535
if (
3636
ts.isClassDeclaration(node) &&
37-
hasDecorators(decorators, ['RegisterResource'])
37+
hasDecorators(decorators, [
38+
'RegisterResource',
39+
'ObjectType',
40+
'InterfaceType',
41+
'InputType',
42+
'ArgsType',
43+
])
3844
) {
3945
return this.enhanceDtoClass(node, program, factory);
4046
}

0 commit comments

Comments
 (0)