The documentation might seem a bit complex, so here’s a streamlined version:
First, define the namespace and key in your run.graphql file like this:
metafield(namespace: "custom", key: "discount_value")
Next in the extensions toml file you need to identify it:
[extensions.input.variables]
namespace = "
Lastly, when creating the actual meta tag for what ever route/mutation you use in the admin you will push the **Product** & **Customer** tag using the name space:
```markup
const response = await admin.graphql(
`#graphql
mutation CreateAutomaticDiscount($discount: DiscountAutomaticAppInput!) {
discountCreate: discountAutomaticAppCreate(automaticAppDiscount: $discount) {
automaticAppDiscount {
discountId
}
userErrors {
code
message
field
}
}
}`,
{
variables: {
discount: {
...baseDiscount,
metafields: [
{
namespace: "
Now in your Graphql file you can import the dynamic variable (tags for product/customer) like you would a graphql variable.
```markup
query RunInput($customer_tag: String! = "default-tag") {
cart {
lines {
quantity
merchandise {
__typename
... on ProductVariant {
id
}
}
}
buyerIdentity {
customer {
hasTags(tags: $customer_tag) {
tag
hasTag
}
}
}
}
discountNode {
metafield(namespace: "
Here I named the graphql input variable **customer_tag**. Be sure you match the grapql variable input with the one you called in the name space when making the metafeild (as shown when creating the discount). That is crucial.
Now you are ready.
1. Finalize by running shopify app function schema and **shopify app function schema** and shopify app function typegen. Next you can run s**hopify app dev** but at times that isn't sufficient and you will need to s**hopify app** **deploy** prior to testing. Lastly, you can test the functionality and check the extensions STDOUT in the partner dashboard within your app.