A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
I use GraphQL to filter product.
This case, I filter by product_type.
query test{
products(first: 20, query:"product_type:'Dresses'") {
edges{
node{
productType
variants(first:10){
edges{
node{
price
compareAtPrice
}
}
}
}
}
}
}
And result: There are 4 products has product type is "Dresses", and no one in them has discount
{
"data": {
"products": {
"edges": [
{
"node": {
"productType": "Dresses",
"variants": {
"edges": [
{
"node": {
"price": "178.00",
"compareAtPrice": null
}
},
{
"node": {
"price": "178.00",
"compareAtPrice": null
}
},
{
"node": {
"price": "178.00",
"compareAtPrice": null
}
}
]
}
}
},
{
"node": {
"productType": "Dresses",
"variants": {
"edges": [
{
"node": {
"price": "390.60",
"compareAtPrice": null
}
},
{
"node": {
"price": "390.60",
"compareAtPrice": null
}
},
{
"node": {
"price": "390.60",
"compareAtPrice": null
}
},
{
"node": {
"price": "390.60",
"compareAtPrice": null
}
},
{
"node": {
"price": "390.60",
"compareAtPrice": null
}
}
]
}
}
},
{
"node": {
"productType": "Dresses",
"variants": {
"edges": [
{
"node": {
"price": "628.60",
"compareAtPrice": null
}
},
{
"node": {
"price": "628.60",
"compareAtPrice": null
}
}
]
}
}
},
{
"node": {
"productType": "Dresses",
"variants": {
"edges": [
{
"node": {
"price": "453.60",
"compareAtPrice": null
}
},
{
"node": {
"price": "453.60",
"compareAtPrice": null
}
},
{
"node": {
"price": "453.60",
"compareAtPrice": null
}
},
{
"node": {
"price": "453.60",
"compareAtPrice": null
}
}
]
}
}
}
]
}
},
"extensions": {
"cost": {
"requestedQueryCost": 262,
"actualQueryCost": 28,
"throttleStatus": {
"maximumAvailable": 1000.0,
"currentlyAvailable": 972,
"restoreRate": 50.0
}
}
}
}
And then, I filter by is_price_reduced.
query test{
products(first: 20, query:"is_price_reduced:true") {
edges{
node{
productType
variants(first:10){
edges{
node{
price
compareAtPrice
}
}
}
}
}
}
}
And result, there are 16 products and no one in them has product type is "Dress"
{
"data": {
"products": {
"edges": [
{
"node": {
"productType": "Entertainment Centers & TV Stands",
"variants": {
"edges": [
{
"node": {
"price": "30.00",
"compareAtPrice": "50.00"
}
},
{
"node": {
"price": "20.00",
"compareAtPrice": null
}
},
{
"node": {
"price": "20.00",
"compareAtPrice": null
}
}
]
}
}
},
{
"node": {
"productType": "Animals & Pet Supplies",
"variants": {
"edges": [
{
"node": {
"price": "34.30",
"compareAtPrice": "35.00"
}
}
]
}
}
},
{
"node": {
"productType": "Sporting Goods",
"variants": {
"edges": [
{
"node": {
"price": "20.40",
"compareAtPrice": "102.00"
}
},
{
"node": {
"price": "100.98",
"compareAtPrice": null
}
},
{
"node": {
"price": "102.00",
"compareAtPrice": null
}
}
]
}
}
},
{
"node": {
"productType": "Animals & Pet Supplies",
"variants": {
"edges": [
{
"node": {
"price": "5.10",
"compareAtPrice": "10.20"
}
}
]
}
}
},
{
"node": {
"productType": "Baby & Toddler",
"variants": {
"edges": [
{
"node": {
"price": "10.00",
"compareAtPrice": "20.00"
}
}
]
}
}
},
{
"node": {
"productType": "Pet Bowl Mats",
"variants": {
"edges": [
{
"node": {
"price": "111.00",
"compareAtPrice": "222.00"
}
},
{
"node": {
"price": "111.00",
"compareAtPrice": "222.00"
}
},
{
"node": {
"price": "111.00",
"compareAtPrice": "222.00"
}
},
{
"node": {
"price": "111.00",
"compareAtPrice": "222.00"
}
},
{
"node": {
"price": "111.00",
"compareAtPrice": "222.00"
}
},
{
"node": {
"price": "111.00",
"compareAtPrice": "222.00"
}
},
{
"node": {
"price": "111.00",
"compareAtPrice": "222.00"
}
},
{
"node": {
"price": "111.00",
"compareAtPrice": "222.00"
}
},
{
"node": {
"price": "111.00",
"compareAtPrice": "222.00"
}
}
]
}
}
},
{
"node": {
"productType": "cay vot",
"variants": {
"edges": [
{
"node": {
"price": "222.00",
"compareAtPrice": "223.00"
}
}
]
}
}
},
{
"node": {
"productType": "men's denim",
"variants": {
"edges": [
{
"node": {
"price": "404.60",
"compareAtPrice": "500.00"
}
},
{
"node": {
"price": "404.60",
"compareAtPrice": null
}
},
{
"node": {
"price": "404.60",
"compareAtPrice": null
}
}
]
}
}
},
{
"node": {
"productType": "women's dresses",
"variants": {
"edges": [
{
"node": {
"price": "551.60",
"compareAtPrice": "1111.00"
}
},
{
"node": {
"price": "551.60",
"compareAtPrice": null
}
},
{
"node": {
"price": "551.60",
"compareAtPrice": null
}
},
{
"node": {
"price": "551.60",
"compareAtPrice": null
}
},
{
"node": {
"price": "551.60",
"compareAtPrice": null
}
}
]
}
}
},
{
"node": {
"productType": "Womens dresses",
"variants": {
"edges": [
{
"node": {
"price": "313.60",
"compareAtPrice": "1111.00"
}
},
{
"node": {
"price": "313.60",
"compareAtPrice": null
}
},
{
"node": {
"price": "313.60",
"compareAtPrice": null
}
},
{
"node": {
"price": "313.60",
"compareAtPrice": null
}
},
{
"node": {
"price": "313.60",
"compareAtPrice": null
}
}
]
}
}
},
{
"node": {
"productType": "quan furniture",
"variants": {
"edges": [
{
"node": {
"price": "222.00",
"compareAtPrice": "333.00"
}
}
]
}
}
},
{
"node": {
"productType": "Furniture",
"variants": {
"edges": [
{
"node": {
"price": "123.00",
"compareAtPrice": "0.00"
}
},
{
"node": {
"price": "123.00",
"compareAtPrice": null
}
},
{
"node": {
"price": "123.00",
"compareAtPrice": "333.00"
}
},
{
"node": {
"price": "123.00",
"compareAtPrice": "333.00"
}
},
{
"node": {
"price": "123.00",
"compareAtPrice": "333.00"
}
},
{
"node": {
"price": "123.00",
"compareAtPrice": "333.00"
}
}
]
}
}
},
{
"node": {
"productType": "women's dresses",
"variants": {
"edges": [
{
"node": {
"price": "978.00",
"compareAtPrice": "1000.00"
}
},
{
"node": {
"price": "978.00",
"compareAtPrice": null
}
}
]
}
}
},
{
"node": {
"productType": "women's dresses",
"variants": {
"edges": [
{
"node": {
"price": "551.60",
"compareAtPrice": "1111.00"
}
},
{
"node": {
"price": "0.00",
"compareAtPrice": null
}
},
{
"node": {
"price": "551.60",
"compareAtPrice": null
}
},
{
"node": {
"price": "551.60",
"compareAtPrice": null
}
},
{
"node": {
"price": "551.60",
"compareAtPrice": null
}
}
]
}
}
},
{
"node": {
"productType": "Men's Pants",
"variants": {
"edges": [
{
"node": {
"price": "222.88",
"compareAtPrice": "278.60"
}
},
{
"node": {
"price": "222.00",
"compareAtPrice": null
}
},
{
"node": {
"price": "222.88",
"compareAtPrice": "278.60"
}
},
{
"node": {
"price": "222.88",
"compareAtPrice": "278.60"
}
}
]
}
}
},
{
"node": {
"productType": "Men's Pants",
"variants": {
"edges": [
{
"node": {
"price": "200.00",
"compareAtPrice": "278.60"
}
},
{
"node": {
"price": "200.00",
"compareAtPrice": "222.00"
}
},
{
"node": {
"price": "200.00",
"compareAtPrice": "278.60"
}
},
{
"node": {
"price": "200.00",
"compareAtPrice": "278.60"
}
}
]
}
}
}
]
}
},
"extensions": {
"cost": {
"requestedQueryCost": 262,
"actualQueryCost": 104,
"throttleStatus": {
"maximumAvailable": 1000.0,
"currentlyAvailable": 896,
"restoreRate": 50.0
}
}
}
}
Finally, I filter by both product_type and is_price_reduced
query test{
products(first: 20, query:"product_type:'Dresses' AND is_price_reduced:true") {
edges{
node{
productType
variants(first:10){
edges{
node{
price
compareAtPrice
}
}
}
}
}
}
}
Follow the logic, expected result I want is empty. (4 product has product_type "Dresses" do not have discount and 16 products have discount do not have product_type "Dresses")
But this is actually result:
Products have product_type is "women's dresses".
{
"data": {
"products": {
"edges": [
{
"node": {
"productType": "women's dresses",
"variants": {
"edges": [
{
"node": {
"price": "551.60",
"compareAtPrice": "1111.00"
}
},
{
"node": {
"price": "551.60",
"compareAtPrice": null
}
},
{
"node": {
"price": "551.60",
"compareAtPrice": null
}
},
{
"node": {
"price": "551.60",
"compareAtPrice": null
}
},
{
"node": {
"price": "551.60",
"compareAtPrice": null
}
}
]
}
}
},
{
"node": {
"productType": "Womens dresses",
"variants": {
"edges": [
{
"node": {
"price": "313.60",
"compareAtPrice": "1111.00"
}
},
{
"node": {
"price": "313.60",
"compareAtPrice": null
}
},
{
"node": {
"price": "313.60",
"compareAtPrice": null
}
},
{
"node": {
"price": "313.60",
"compareAtPrice": null
}
},
{
"node": {
"price": "313.60",
"compareAtPrice": null
}
}
]
}
}
},
{
"node": {
"productType": "women's dresses",
"variants": {
"edges": [
{
"node": {
"price": "978.00",
"compareAtPrice": "1000.00"
}
},
{
"node": {
"price": "978.00",
"compareAtPrice": null
}
}
]
}
}
},
{
"node": {
"productType": "women's dresses",
"variants": {
"edges": [
{
"node": {
"price": "551.60",
"compareAtPrice": "1111.00"
}
},
{
"node": {
"price": "0.00",
"compareAtPrice": null
}
},
{
"node": {
"price": "551.60",
"compareAtPrice": null
}
},
{
"node": {
"price": "551.60",
"compareAtPrice": null
}
},
{
"node": {
"price": "551.60",
"compareAtPrice": null
}
}
]
}
}
}
]
}
},
"extensions": {
"cost": {
"requestedQueryCost": 262,
"actualQueryCost": 31,
"throttleStatus": {
"maximumAvailable": 1000.0,
"currentlyAvailable": 969,
"restoreRate": 50.0
}
}
}
}
Am I wrong in the syntax?