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.

Shopify Admin API GraphQL Nested Query

Shopify Admin API GraphQL Nested Query

henrytran721
Shopify Partner
1 0 0

Hello! I have a query here for DiscountCode and I want to filter by `createdBy` an external app. I want to retrieve all DiscountCodes that have not been created by an external app however, I'd like to do this query at the top level to return them. Is this possible in this API? Thank you. 

 

 

 

{
  discountNodes(first: 19, query: "status:active", reverse: true) {
    edges {
      node {
        id
        discount {
          ... on DiscountCodeBasic {
            title
            status
            codes(first: 1) {
              edges {
                node {
                  code
                  createdBy {
                    id
                    title
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

 

 

Reply 1 (1)

Eric-HAN
Shopify Partner
273 30 29

Hi , there

 Appears that there is no direct method to filter DiscountCodes based on the createdBy field. However, you can retrieve all the discount codes through a query and then apply manual filtering in your program logic.  what do you think?

- Helpful? Please hit Like and mark it as a solution
Want to modify or custom changes on store? Let me help.
- Feel free to Email Me    Buy Me A Coffee