Not able to add customers to price rule discounts using GraphQL API

I am trying to add customer IDs to an existing price rule discount using the admin GraphQL API:
https://shopify.dev/api/admin-graphql/2022-04/mutations/priceRuleUpdate – find: customerIdsToAdd

However, when I try this, I get the following error: “Field ‘customerIdsToAdd’ doesn’t exist on type ‘PriceRuleCustomerSelection’”

Here’s a full screen shot from the Shopify GraphiQL App:

https://prnt.sc/h8FBOFcXmH7T

What am I missing?

Finally figured it out. Something has to be listed under “customerSelection”, just not “customerIdsToAdd”:

mutation priceRuleUpdate($id: ID!, $priceRule: PriceRuleInput!) {
  priceRuleUpdate(id: $id, priceRule: $priceRule) {
    priceRuleUserErrors {
      field
      message
      code
    }
    priceRule {
      id
      customerSelection {
        forAllCustomers
      }
    }
  }
}

1 Like