I’m trying to build a discount function that will apply a different discount based on customer tags. I’m trying to figure out how to do it with the app metafield but I can’t seem to get the metafield data through the GraphQL app.
Here’s what’s going on, here’s my Discount Function’s InputQuery
query RunInput {
cart {
buyerIdentity{
customer{
id,
hasAnyTag
}
}
lines {
quantity
merchandise {
__typename
...on ProductVariant {
id
}
}
}
}
discountNode {
metafield(namespace: "$app:volume-discount", key: "function-configuration") {
value,
}
}
}
That works perfectly well and yields the data from the discount I created in the admin UI:
{
"customer_tag": "new-customer",
"excluded_products": "",
"amount": 20,
"percentage": true
}
But in using the Shopify GraphQL app, if I put in this query:
query MyQuery {
discountNodes(first: 5) {
nodes {
metafields(first: 1) {
nodes {
key
namespace
}
}
id
discount {
... on DiscountAutomaticApp {
title
}
}
}
}
}
I get this output:
{
"data": {
"discountNodes": {
"nodes": [
{
"metafields": {
"nodes": []
},
"id": "gid://shopify/DiscountAutomaticNode/1438023254326",
"discount": {
"title": "Third Test"
}
},
{
"metafields": {
"nodes": []
},
"id": "gid://shopify/DiscountAutomaticNode/1438842224950",
"discount": {
"title": "October 17"
}
}
]
}
},
"extensions": {
"cost": {
"requestedQueryCost": 27,
"actualQueryCost": 11,
"throttleStatus": {
"maximumAvailable": 1000,
"currentlyAvailable": 989,
"restoreRate": 50
}
}
}
}
Can anybody tell me why there’s no metafield data for these items when I can pull it from in the InputQuery?