You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It appears to me that parent requirements do not work for collections, when requiring a sub field that happens to be part of an item within a collection:
public class Order
{
public int OrderId { get; set; }
public ICollection<Item> Items { get; set; }
}
public class Item
{
public int ItemId { get; set; }
public decimal Price { get; set; }
}
[BindMember("totalPrice")]
[UseProjection]
public static async Task<decimal?> GetTotalPrice([Parent("Items { Price }")] Order order)
{
return order.Items.Sum(i => i.Price);
}
This results in an error message that the field requirement does not exist - raised in the PropertyTreeBuilder CollectProperties method:
The field requirement /Items/Price does not exist on Order.TotalPrice.
When the method traverses the defined require query of the Parent attribute, it uses the GetProperty method of .NET reflection to collect each class property for each selected field (CollectProperties method). This works fine as long as there is no collection involved. In my sample the first property node for Items get resolved successfully, but when resolving the "Price" field the GetProperty method is called on the type of ICollection.
Is this not yet supported or am I missing GraphQL specific issues why this is not implemented?
The solution you'd like
I can require Collections too and use that for projections.
The text was updated successfully, but these errors were encountered:
Product
Hot Chocolate
Is your feature request related to a problem?
It appears to me that parent requirements do not work for collections, when requiring a sub field that happens to be part of an item within a collection:
This results in an error message that the field requirement does not exist - raised in the PropertyTreeBuilder CollectProperties method:
The field requirement
/Items/Price
does not exist onOrder.TotalPrice
.When the method traverses the defined require query of the Parent attribute, it uses the GetProperty method of .NET reflection to collect each class property for each selected field (CollectProperties method). This works fine as long as there is no collection involved. In my sample the first property node for Items get resolved successfully, but when resolving the "Price" field the GetProperty method is called on the type of ICollection.
Is this not yet supported or am I missing GraphQL specific issues why this is not implemented?
The solution you'd like
I can require Collections too and use that for projections.
The text was updated successfully, but these errors were encountered: