Skip to content

Commit 6805860

Browse files
committed
Allow EnhancedResource.resolve to work just like .of for objects
Not requiring the `ResourcesHost` service to exist. So ``` EnhancedResources.of(User) EnhancedResources.resolve(User) ``` both work even if the app is not booted. I don't have a concrete use case for this; it just feels like the right thing to do
1 parent 7a4eefe commit 6805860

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/common/resource.dto.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ export class EnhancedResource<T extends ResourceShape<any>> {
107107
>();
108108

109109
static resolve(ref: ResourceLike) {
110+
if (ref && typeof ref !== 'string') {
111+
return EnhancedResource.of(ref);
112+
}
110113
if (!EnhancedResource.resourcesHost) {
111114
throw new ServerException('Cannot resolve without ResourcesHost');
112115
}

0 commit comments

Comments
 (0)