A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
Is there any way to fetch all the discounts of a store both automatic and discount codes using a single query?
Solved! Go to the solution
This is an accepted solution.
Hi @sandeepks23
For REST requests unfortunately not. The single way that I found is a two steps request.
The first request is to all price_rules and then to all discount codes inside each rule.
But graphQL request it is potentially possible.
But I don't dive deep into graphQL priceRules api.
There is nothing about discount codes in the docs https://shopify.dev/api/admin-graphql/2021-10/queries/priceRules 😞
This is an accepted solution.
Hi @sandeepks23
For REST requests unfortunately not. The single way that I found is a two steps request.
The first request is to all price_rules and then to all discount codes inside each rule.
But graphQL request it is potentially possible.
But I don't dive deep into graphQL priceRules api.
There is nothing about discount codes in the docs https://shopify.dev/api/admin-graphql/2021-10/queries/priceRules 😞
Thanks for that. But when I tried to execute these queries I got an error as "This app is not approved to access the PriceRule object". But in our app we have given the "read_price_rules" in access scope.
You might need to reauthenticate/reinstall app after changing scopes
Still got the same issue after reinstalling again