Hi!
I’m developing an app with Strapi V4. I have a content-type that has a “single” component that in turn has two fields. When I’m updating individual fields of the component via REST API all its other fields get nulled. Even those marked as required. Here’s an example using the familiar Restaurant model:
// A valid Restaurant instance might look something like this:
{
id: 2,
name: "Kimchi Kitchen",
type: "asian",
// This is a single component.
address: {
id: 5,
street: "5 Ave",
city: "Haarlem"
}
}
When I update this Restaurant with
{
data: {
type: "italian"
}
}
Only the type
is updated and all other fields keep their value. That’s expected.
However, when I update it with
{
data: {
address: {
street "10 Ave",
}
}
}
I get a Restaurant, where address.city === null
. Also, even if the city
field is marked as required
no errors are thrown and the update gets through resulting in invalid data.
Is there a way to update components partially? If not can I at least prevent API clients from creating invalid data? Shall I report that as a bug?