I am trying to select discount codes assigned to a logged-in user using admin graphql API. I am able to select all discount codes but I am not able to filter them by customer ID or customer email address. Here is my GQL. Can you guide me on how can limit the results to specified customers?
{
priceRules(first: 10, reverse: true) {
nodes {
customerSelection {
customers(first: 10) {
edges {
node {
id
email
}
}
}
}
title
}
}
}
1 Answer
According to the docs at here , the customers
field supports a argument called query which supports the filtering the follows :
- accepts_marketing
- country
- customer_date
- last_abandoned_order_date
- order_date
- orders_count
- phone
- state
- tag
- tag_not
- total_spent
- updated_at
And based on the doc of the query syntax , think that the customer email can be filtered by :
{
priceRules(first: 10, reverse: true) {
nodes {
customerSelection {
customers(first: 10,query :"email:[email protected]") {
edges {
node {
id
email
}
}
}
}
title
}
}
}