Ways to narrow down discounts query to return AppDiscounts

Topic summary

Problem Identified:

Developers creating custom discounts via Shopify Functions face challenges querying those discounts efficiently. The discountNodes query requires fetching potentially hundreds of discounts without proper filtering options, causing:

  • Query budget exhaustion
  • Risk of hitting cost limits
  • automaticDiscountNodes returning empty results

Desired Filtering Capabilities:

  • Filter by AppDiscounts only
  • Filter by DiscountAutomaticNode type
  • Filter by function name or app ID

Workaround Solution:

A community member discovered undocumented query parameters:

  • Use query:"type:app AND method:automatic" to filter DiscountAutomaticApp nodes
  • method accepts “automatic” or “code”
  • discount_type limited to “bogo, fixed_amount, free_shipping, percentage”

Remaining Limitations:

  • No filtering by App ID, function ID, or API key
  • Must filter results in application code using DiscountAutomaticApp.appDiscountType.app.apiKey
  • Pagination with exponential backoff required to avoid throttling
  • Documentation gaps acknowledged by Shopify staff, who will pass feedback to the team
Summarized with AI on October 28. AI used: claude-sonnet-4-5-20250929.

Hi Folks,

I have created few custom discounts, with the use of Shopify Functions + Apps.

I use the discountAutomaticAppCreate to create the discounts in the Admin API.

Then I would like to query for those created discounts.

This is when I use discountNodes query (strangely automaticDiscountNodes query does not return the discounts)

The problem is that in my shop there are literally hundreds of active Discounts, so when I query I need to set very high first parameter, which then in turn quickly evaporates the query budget. As the number of active discount increases the likelihood of hitting the query cost limit increases to the point where I can no longer trust to actually receive my desired data.

So. This is when I would like to query for my discounts with a narrower set of arguments.

I.e. I would like to be able to narrow down the query to i.e. :

  • get me all the AppDiscounts
  • get me all the DiscountAutomaticNode discounts
  • get me all the discounts by name (the name of the Discount Function not the name of a single discount)

However, either the query param does not allow for this or it’s simply not documented.

Do you have any ideas on how to proceed with implementing a robust way of querying custom discounts?

1 Like

Hey Filip,

This is a case where paginating through your results is going to be the best option. You can’t always get all of the data that you need in 1 shot, but paginating through the results will give your app some time to recover your call limit.

I can definitely see how more filter options would be beneficial here though, thanks for the feedback. I’ll pass it along to the team!

+1 to this.

automaticDiscountNodes always returns an empty list.

Having to query all the user’s discount nodes is a waste of compute + bandwidth. For example, some users may have 100+ discounts in their store, especially if they use a bundle app that automatically creates discounts in bulk.

In order to query every page of discountNodes, we have to implement exponential backoff to avoid throttling, which ultimately results in slow load times for users.

As far as query parameters in discountNodes, these are the ones I’m curious about:

  • discount_type - could this be a way to filter out DiscountAutomaticApp, or a specific function ID?
  • method - not sure what this means.

But unfortunately, there’s no documentation.

1 Like

After some fiddling around, I learned:

So, you can filter DiscountAutomaticApp nodes using `query:“type:app AND method:automatic”

There’s no way to filter by App ID/function ID/API key. So you’ll just have to use the query above, and then filter nodes in your own code based on DiscountAutomaticApp.appDiscountType.app.apiKey.

Hope this helps.

6 Likes

Thank you very much. This is very helpful!

Thanks for this response! I couldn’t figure out how to query the Shopify API for my Shopify Discount Functions but this really helped me out. I wish this kind of stuff was better documented in the Shopify API docs.

1 Like