When I dispatch an Add-Action my Backend is updated and so is my Frontend (due to optimisticAdd: true).
But I still get this Error:
I debugged everything and found the place where the error happens:
The function mustBeEntity(action){...}
is called three times. On the third time
const id = this.selectId(data);
returns undefined, even though data has an valid id called 'id'.
I tried setting the selectId in the EntityMetaData resulting in the same Error.
Here is my EntyityMetadata:
const entityMetadata: EntityMetadataMap = {
User: {
selectId: (user: User) => user.id,
entityName: 'User',
entityDispatcherOptions: {
optimisticAdd: true,
optimisticDelete: true,
optimisticUpdate: true,
optimisticUpsert: true
}
}
};
And here is my User Interface:
export interface User {
id: number
firstname: string,
lastName: string,
}
I also got some Screenshots where you can exactly see, that it returns undefined even tho the id is clearly there:
The user got an Id of 5, but then:
Is this a bug or do I misunderstand something?
I already Had a look at this Question: ngrx/data - alternate id `has a missing or invalid entity key (id)`
But the only solution provided there is not the problem in my case!