Discussing Shopify Functions development, deployment, and usage in Shopify apps.
I can get value of one field but i need to get two or more metafields. If it is possible, I need to know how is the structure of input.graphql
Solved! Go to the solution
This is an accepted solution.
Hi @RickyMagana -- You can use GraphQL field aliases for this.
discountNode {
metafield1: metafield(namespace: "$app:my-app", key: "key1") {
value
}
metafield2: metafield(namespace: "$app:my-app", key: "key2") {
value
}
}
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
This is an accepted solution.
Hi @RickyMagana -- You can use GraphQL field aliases for this.
discountNode {
metafield1: metafield(namespace: "$app:my-app", key: "key1") {
value
}
metafield2: metafield(namespace: "$app:my-app", key: "key2") {
value
}
}
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
Thank you so much, now my function works fine.
I got it working
key and namespace values were wrong
metafield (key:"locality", namespace:"custom"){
value
}
Here is my graphql file, works very well.
query Input {
cart {
lines {
quantity
merchandise {
__typename
...on ProductVariant {
id,
product {
handle,
boxcontains: metafield(namespace: "custom", key: "box_contains") {
value
},
percentagediscountbox: metafield(namespace: "custom", key: "percentage_discount_per_box") {
value
},
}
}
}
cost {
totalAmount {
amount
}
}
}
}
discountNode {
metafield(namespace: "volume-discount", key: "volume-config") {
value
}
}
}