GraphQL API Discounts: download all non personal discount codes

GraphQL API Discounts: download all non personal discount codes

ddofborg
Shopify Partner
4 0 0

We need to download all non personal discount codes using GraphQL API.

 

At the moment we download ALL discounts and check if the `customerSelection` is empty. This means that the code is for all customers. Below is the gist of the query. We would like to filter out all discounts which are personal, because in some cases apps generate discount codes for each buyer and this generated a huge amount of code which are useless for our app.

 

 

{
    discountNodes(query:"status:active") {
        edges {
            node {
                id
                discount {
                    __typename
                    ... on DiscountCodeBasic {
                        title
                        summary
                        ## more fields ##
                        customerSelection {
                            ... on DiscountCustomerAll {
                                allCustomers
                            }
                        }
                        discountClass
                        status
                    }
                }
            }
        }
    }
}

 

 

Replies 0 (0)