Skip to content

PATCH request doesn't save relationships #60

Closed
@jfhs

Description

@jfhs

PATCH request for entities having relationships doesn't save them.

For HasOne relationships possible solution is to have code like this in DefaultRepository.UpdateAsync:

_jsonApiContext.RequestEntity.Relationships.ForEach(rel =>
{
	if (rel.IsHasOne)
	{
		var propertyInfo = entity.GetType().GetProperty($"{rel.InternalRelationshipName}Id");
		propertyInfo.SetValue(oldEntity, propertyInfo.GetValue(entity));
	}
});

However with HasMany I am not sure what is the right way. Looking to what ember-data sends, it seems that "direct" (meaning that it's not many-to-many relationship) has-many relationships are not sent with entity. Instead you should save them separately.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions