add DSONameService

This commit is contained in:
Art Lowel
2020-02-26 13:58:09 +01:00
parent f67387ed65
commit 5b326aea92
6 changed files with 193 additions and 12 deletions

View File

@@ -55,16 +55,20 @@ export class LinkService {
parent: this.parentInjector
}).get(provider);
const href = model._links[matchingLinkDef.linkName].href;
const link = model._links[matchingLinkDef.linkName];
try {
if (matchingLinkDef.isList) {
model[linkToFollow.name] = service.findAllByHref(href, linkToFollow.findListOptions, ...linkToFollow.linksToFollow);
} else {
model[linkToFollow.name] = service.findByHref(href, ...linkToFollow.linksToFollow);
if (hasValue(link)) {
const href = link.href;
try {
if (matchingLinkDef.isList) {
model[linkToFollow.name] = service.findAllByHref(href, linkToFollow.findListOptions, ...linkToFollow.linksToFollow);
} else {
model[linkToFollow.name] = service.findByHref(href, ...linkToFollow.linksToFollow);
}
} catch (e) {
throw new Error(`Something went wrong when using @dataService(${matchingLinkDef.resourceType.value}) ${hasValue(service) ? '' : '(undefined) '}to resolve link ${linkToFollow.name} from ${href}`);
}
} catch (e) {
throw new Error(`Something went wrong when using @dataService(${matchingLinkDef.resourceType.value}) ${hasValue(service) ? '' : '(undefined) '}to resolve link ${linkToFollow.name} from ${href}`);
}
}
return model;