-
Notifications
You must be signed in to change notification settings - Fork 50
Open
Description
When I use a Service to get a Resource and use include to also fetch data for relationships, I need to construct the Service for the included Resource(s) for it to work.
Taking the demo as example:
public constructor(private booksService: BooksService) {
booksService
.all({
include: ['author']
}).subscribe(books => {
console.log(books);
})
}
will return a DocumentCollection with all books, where every Book has an author relationship. But when you look at the data in this author Resource, it is empty. It does have the correct id, but attributes is a completly empty object.
Only when I also inject the AuthorsService, the attributes for the included author are loaded.
public constructor(private booksService: BooksService, private authorService: AuthorsService) {
booksService
.all({
include: ['author']
}).subscribe(books => {
console.log(books);
})
}
I am not using the AuthorService anywhere, just injecting it and thus constructing it is enough.
Metadata
Metadata
Assignees
Labels
No labels