How can I get all tags or product tags starting with a specific string in shopify functions graphql?

How can I get all tags or product tags starting with a specific string in shopify functions graphql?

mjzap
Shopify Partner
3 0 0

In the below code, I want to get all tags or tags starting with a specific string on the customer and/or product.
How can I do it?

query RunInput {
cart {
buyerIdentity {
customer {
numberOfOrders
}
}
cost {
subtotalAmount {
amount
}
}
lines {
quantity
merchandise {
... on ProductVariant {
product {
id
handle
hasTags(tags: ["some string"]) {
tag
hasTag
}
max_orders: metafield(namespace: "custom", key: "max_amount") {
value
}

}
}
}
}
}
}
Replies 3 (3)

Nick_Wesselman
Shopify Staff
171 43 70

Hi @mjzap --

This is not currently possible with Functions, as they require you to request a specific tag for performance reasons. Can you describe more about your use case? You might consider user-configured tags with input query variables, or use of metafields instead.

-Nick

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

mizzimizzi
Shopify Partner
5 0 0

Hi,

 

The use case could be an app that manages various types of discounts by applying tags to a product.

Tags contain an identifying prefix (common for all discounts) and a series of information related to the discount (for example the type of discount and the value of the discount), something like "promo:2:value:10" or "promo:20:value:7". Receiving all the tags that start with promo would allow me to have the list of discounts to apply. The same result can be achieved receiving the complete list of tags and filtering all tags with a certain prefix.

 

Do you have any suggestions for solving this problem using tags?

Nick_Wesselman
Shopify Staff
171 43 70

This looks like a scenario where we would recommend moving to metafields, instead of embedding values into a tag string.

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