Closed
Description
For a simple model like below
public class Customer : Identifiable
{
[HasMany] public List<Order> Orders { get; set; }
}
public class Order : Identifiable
{
[HasMany] public List<Invoice> Invoices { get; set; }
}
public class Invoice : Identifiable { }
Serializer works fine and get customer with included relationship returns the desired response
/api/v1/customers?included=orders.invoices
{
"data": {
"attributes": {},
"relationships": {
"orders": {
"links": {
"self": "https://localhost:44351/customers/1234/relationships/orders",
"related": "https://localhost:44351/customers/1234/orders"
},
"data": [
{
"type": "orders",
"id": "4567"
}
]
}
},
"type": "customers",
"id": "1234"
},
"included": [
{
"attributes": {},
"relationships": {
"invoices": {
"links": {
"self": "https://localhost:44351/orders/4567/relationships/invoices",
"related": "https://localhost:44351/orders/4567/invoices"
},
"data": [
{
"type": "invoices",
"id": "7890"
}
]
}
},
"type": "orders",
"id": "4567"
},
{
"attributes": {},
"type": "invoices",
"id": "7890"
}
]
}
However on using the same json as input for post/put operation and trying to deserialize into customer instance with all fields/relationships populated, it does not load included relationship.
In this instance, customer has orders attributes populated but invoices is appearing blank.
Is it because we are only setting attributes and not relationship. Can we please modify it to add second level or more relationship be included as well.