Чего мне здесь не хватает?
Нужно ли мне писать собственный фильтр?
Код BE:
Код: Выделить всё
public partial class Query
{
[UseFiltering(typeof(ExceptionDetailsByStockNumberFilterType))]
public async Task GetExceptionDetailsByStockNumberAsync(
IReadOnlyList stockNumber,
ExceptionByStockNumberRequestDto exceptionByStockNumberRequest,
CancellationToken cancellationToken,
[Service(ServiceKind.Synchronized)] IExceptionService exceptionService)
=> await exceptionService.GetExceptionDetailsByStockNumbersAsync(stockNumber, exceptionByStockNumberRequest, cancellationToken);
}
Код: Выделить всё
public class ExceptionDetailsByStockNumberFilterType: FilterInputType
{
protected override void Configure(IFilterInputTypeDescriptor descriptor)
{
descriptor.Ignore(x => x.Id);
descriptor.Ignore(x => x.CreatedBy);
descriptor.Ignore(x => x.StockNumber);
descriptor.Ignore(x => x.Vin);
base.Configure(descriptor);
}
}
Код: Выделить всё
[GraphQLName("ExceptionDetailsDto")]
public class ExceptionDetailsByStockDto
{
public string Id { get; set; }
public string StockNumber { get; set; }
public string Vin { get; set; }
public IEnumerable[*] LineItems { get; set; }
public IEnumerable
Payments { get; set; }
public string CreatedBy { get; set; }
}
Код: Выделить всё
{
"data": {
"exceptionDetailsByStockNumber": [
{
"vin": "2G1WB58K381303600",
"lineItems": [
{
"itemState": "Reconciled",
"reconciliationStatus": "Matched"
},
{
"itemState": "Exception",
"reconciliationStatus": "Duplicate"
}
]
}
]
}
}
Код: Выделить всё
{
"data": {
"exceptionDetailsByStockNumber": [
{
"vin": "2G1WB58K381303600",
"lineItems": [
{
"itemState": "Exception",
"reconciliationStatus": "Duplicate"
}
]
}
]
}
}
с где: { lineItems: { all: { itemState: { eq: "Exception" } } }
Код: Выделить всё
query {
exceptionDetailsByStockNumber(
stockNumber: "2002705823"
where: { lineItems: { all: { itemState: { eq: "Exception" } } } }
) {
vin
lineItems {
itemState
reconciliationStatus
}
}
}
Код: Выделить всё
where: { lineItems: { some: { itemState: { contains: "Exception" } } } }
Код: Выделить всё
where: { lineItems: { none: { itemState: { eq: "Reconciled" } } } }
Подробнее здесь: https://stackoverflow.com/questions/787 ... built-filt