shopify-app

Is there away to pass a function id to the run.graphql query in Shopify?


Suppose I deploy multi discounts using the same function for shopify. Is there away I can pass a discount id to run.graphql?

In example:

query RunInput {
  discountNode {
    metafield(namespace: "I want to pull a discount id, how can I pass it dynamically here?", key: "function-configuration") {
      value
    }
  }
}

Solution

  • Here is a modified code that can help you pass a discountID variable dynamically.

    query RunInput($discountId: ID!) {
      discountNode(id: $discountId) {
        metafield(namespace: "your-namespace", key: "function-configuration") {
          value
        }
      }
    }

    Hope it helps!