GraphQL admin API - how to get customer segments from Discount?

Shopify Partner
19 0 1


Whenever I add customerSelection, the graphql syntax checker says that the field is unavailable.

How can I get the segment that can use the discount code?


Thank you

Reply 1 (1)

Shopify Staff
1322 218 457

Hey @begginer1231, thanks for getting in touch - you should be able to use CustomerSelection as a connection under codeDiscountNodes. You just have to include the typename field in the query, so that it includes the type names for each customer selection like this:


codeDiscountNodes(first: 10) {

nodes {


codeDiscount {

... on DiscountCodeBasic {


customerSelection {









Hope this helps - let us know if we can clarify anything further! 

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit or the Shopify Web Design and Development Blog