Hello, I have created a “Discounts Shipping - Function” through the CLI, I have successfully created an interface in the admin panel that saves data that are then read by run.graphql and used in run.ts
Thats mega awesome, however, I need to show a list of discounts issued from the functionId
Basically I need all automatic shipping discount data issued from a specific function id, is that possible?
I created this:
query {
discountNodes(first: 10) {
nodes {
id
discount {
__typename
... on DiscountAutomaticApp {
title
startsAt
endsAt
status
discountId
appDiscountType {
title
functionId
}
combinesWith {
orderDiscounts
productDiscounts
shippingDiscounts
}
}
}
}
}
}
That renders something similar to:
{
"data": {
"discountNodes": {
"nodes": [
{
"id": "gid://shopify/DiscountCodeNode/1691885633862",
"discount": {
"__typename": "DiscountCodeBasic"
}
},
{
"id": "gid://shopify/DiscountCodeNode/1695324504390",
"discount": {
"__typename": "DiscountCodeFreeShipping"
}
},
{
"id": "gid://shopify/DiscountAutomaticNode/1695540904262",
"discount": {
"__typename": "DiscountAutomaticApp",
"title": "Discount - Shipping",
"startsAt": "2022-06-22T00:00:00Z",
"endsAt": null,
"status": "ACTIVE",
"discountId": "gid://shopify/DiscountAutomaticNode/1695540904262",
"appDiscountType": {
"title": "Discount - Shipping",
"functionId": "536930e4-1f2d-439e-9652-832624434e62"
},
"combinesWith": {
"orderDiscounts": true,
"productDiscounts": true,
"shippingDiscounts": false
}
}
},
{
"id": "gid://shopify/DiscountAutomaticNode/1695630000454",
"discount": {
"__typename": "DiscountAutomaticFreeShipping"
}
}
]
}
},
"extensions": {
"cost": {
"requestedQueryCost": 18,
"actualQueryCost": 8,
"throttleStatus": {
"maximumAvailable": 2000,
"currentlyAvailable": 1992,
"restoreRate": 100
}
}
}
}
I could use the above and just map/filter the result and only keep the ones with the functionId of: “536930e4-1f2d-439e-9652-832624434e62”
The problem is, that’s redundant, right? That cant possibly be the “best/better” way to do it?
Can someone help me with a more performant query that only gets the discounts tied to a specific functionId? ![]()
