Retrieving all discount codes via GraphQL that were created by shop admin

Jon_Schwartz
Shopify Expert
75 0 42

Hi all,

I'm trying to retrieve all PriceRules/DiscountCodes that were not created by a 3rd party app. Looks like I can see the app handle of "shopify_web" but can I filter by this app via the query? Or would I just query all rules/codes and then filter the results by the app handle? Current query:

{ priceRules(first: 100,sortKey:CREATED_AT,reverse:true) { edges {
            node {              
              title,              
              summary,
              startsAt,
              endsAt,
              app {
                  handle
              }
            }
            cursor
          },
          pageInfo {
              hasNextPage
          }
        } }

 

Thanks in advance for any thoughts!

0 Likes
Greg_Kujawa
Shopify Partner
1016 83 238

I don't see app.handle listed as query criteria. So you would presumably need to iterate through the entire results set, just keeping those records that you are interested in. Rather than the cursor-based query, I would recommend just using bulk operation for a one-shot deal. Especially if it's a lot of records.