How to use variable in input.graphql

How to use variable in input.graphql

Adam_Čvikota
Shopify Partner
18 0 5

Hello,

I am working on app which implement shopify functions. I create products discount function and all is working fine for me. Now, i try to use variables in input.graphql. I want to offer products discount only to customers with selected tags. Only way i know to do it, is hard coded customers tags in input.graphql (i am sending print screen in attachement). Is there some way i can use dynamic variable with customers tags in input.graphql? For example, can i use customers tags variable from metafield there somehow? If yes, can you plase write me example how to use it in input.graphql and main.rs?

Thank you so much.Screen Shot 2022-11-18 at 10.02.46.png

Replies 4 (4)

Nick_Wesselman
Shopify Staff
171 43 70

Hi @Adam_Čvikota! We don't support this yet, but it's in the roadmap for the near future. We intend to have a mechanism for you to define variable values for the input query.

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

andrewcc
Shopify Partner
1 0 1

Did you ever get this to work? I want to just load the customer tags here.

Nick_Wesselman
Shopify Staff
171 43 70

Variables are now supported in input queries, details are here:

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

sherpabot
Shopify Partner
37 3 4

I am having the same problem. 

I found this: 
https://shopify.dev/docs/api/functions/reference/order-discounts/graphql/common-objects/customer

Where it returns a simple boolean if one of the list of tags is in the customer tags. Whereas the other returns an object with boolean and the tag's themselves.