Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

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

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

begginer1231
Shopify Partner
19 0 1

begginer1231_0-1674787844056.png

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)

ShopifyDevSup
Shopify Staff
1453 238 530

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 {

id

codeDiscount {

... on DiscountCodeBasic {

title

customerSelection {

__typename

}

}

}

}

}

}

 

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 Shopify.dev or the Shopify Web Design and Development Blog