How can i get two or more product metafields in input query?

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

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
    }
  }
2 Likes

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
}
}
}