I have a query response like below. Here, I want to filter out record where "itemState" is "Exception"
. I am trying to use in build filter but looks like it is not working as expected. I tried several approaches but not getting desired approach.
What am I missing here?
Do I need to write custom filter?
{
"data": {
"exceptionDetailsByStockNumber": [
{
"vin": "2G1WB58K381303600",
"lineItems": [
{
"itemState": "Reconciled",
"reconciliationStatus": "Matched"
},
{
"itemState": "Exception",
"reconciliationStatus": "Duplicate"
}
]
}
]
}
}
Desired Result:
{
"data": {
"exceptionDetailsByStockNumber": [
{
"vin": "2G1WB58K381303600",
"lineItems": [
{
"itemState": "Exception",
"reconciliationStatus": "Duplicate"
}
]
}
]
}
}
Graph QL:
with where: { lineItems: { all: { itemState: { eq: "Exception" } } } }
query {
exceptionDetailsByStockNumber(
stockNumber: "2002705823"
where: { lineItems: { all: { itemState: { eq: "Exception" } } } }
) {
vin
lineItems {
itemState
reconciliationStatus
}
}
}
Other approaches:
where: { lineItems: { some: { itemState: { contains: "Exception" } } } }
where: { lineItems: { none: { itemState: { eq: "Reconciled" } } } }