Discussing Shopify Functions development, deployment, and usage in Shopify apps.
I'm trying to use a variable in my input query for a shipping customisation function.
I've followed the steps here https://shopify.dev/docs/apps/functions/input-output/variables-queries
But I'm getting the following error
Validation errors
• input.variables: Variable definitions are missing. Ensure you have defined them in your extension
configuration and that you are using a supported CLI version. See documentation for details:
https://shopify.dev/api/functions/input-query-variables
My shopify cli is at the latest available version (3.50.1)
My extensions/my-delivery-customisation/shopify.extension.toml file looks like this
api_version = "2023-10"
[[extensions]]
handle = "my-delivery-customization"
name = "t:name"
description = "t:description"
type = "function"
[[extensions.targeting]]
target = "purchase.delivery-customization.run"
input_query = "src/run.graphql"
export = "run"
[extensions.build]
command = ""
path = "dist/function.wasm"
[extensions.ui.paths]
create = "/"
details = "/"
[input.variables]
namespace = "$app:my-delivery-function"
key = "shipping-config"
My query looks like this
query RunInput($freeTags: [String!]) {
cart{
buyerIdentity {
email
customer{
isVIP: hasAnyTag(tags: $freeTags)
}
}
deliveryGroups {
deliveryOptions {
title
handle
}
}
}
}
I have created a json metafield with that key and that namespace.
Thank you for your help
Solved! Go to the solution
This is an accepted solution.
Ok the problem was that (differently from what the documentation says) the right syntax is this:
[extensions.input.variables]
namespace = "$app:my-delivery-function"
key = "shipping-config"
This is an accepted solution.
Ok the problem was that (differently from what the documentation says) the right syntax is this:
[extensions.input.variables]
namespace = "$app:my-delivery-function"
key = "shipping-config"
Thanks for posting the solution -- we indeed have a doc update in the works for this.
Nick Wesselman | Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit the Shopify Help Center or the Shopify Blog
I am also doing the same thing but after writing this
[extensions.input.variables]
namespace = "payment-customization"
key = "function-configuration"
metafield giving Null, I am stucked to solve this issue.
Are you using the $app prefix? Try to not use that and see if it works.
No, I am not using $app (reserved prefix) for this.
When you say 'metafield giving null', are you getting the "Variable Definitions Are Missing" error, or is the metafield coming back null in your input query?
These are two different but related uses of metafields in Functions.
https://shopify.dev/docs/apps/functions/input-output/queries-metafields
https://shopify.dev/docs/apps/functions/input-output/variables-queries
Nick Wesselman | Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit the Shopify Help Center or the Shopify Blog
Yes, in input query it's giving null. Getting this response
I responded in your other thread.
Nick Wesselman | Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit the Shopify Help Center or the Shopify Blog