Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relationships only included when corresponding service is constructed #338

Open
TimmayNL opened this issue Nov 22, 2021 · 1 comment
Open

Comments

@TimmayNL
Copy link

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.

@arrgson
Copy link

arrgson commented Jan 16, 2023

I have a similiar issue ... included resource's attributes are sometimes available and sometimes missing. (If I refresh the page 10 times about 2-3 times the attributes are missing. The ID and the type is there, but the attribues are empty.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants