# Shopify function input Query value

**URL:** <https://community.shopify.com/t/shopify-function-input-query-value/330528>\
**Category:** Functions\
**Tags:** optimization, input-queries\
**Created:** [June 10, 2024, 8:58pm UTC](https://community.shopify.com/t/shopify-function-input-query-value/330528 "2024-06-10T20:58:34Z")\
**Posts on this page:** 1\
**Page:** 1

## AI-generated summary

Issue: Variables in a Shopify discount function’s input query aren’t affecting product checks. The developer expects product.inAnyCollection(ids: $selectedCollectionIds) and product.hasAnyTag(tags: $tags) to return true but gets false.

Setup: The RunInput GraphQL query declares variables ($selectedCollectionIds: [ID!], $tags: [String!]) and also reads a configuration metafield (namespace: some-product-discounts, key: function-configuration) whose JSON contains selectedCollectionIds ["gid://shopify/Collection/471875060002"] and tags ["hero"].

Observed: For a cart line with product gid://shopify/Product/7984435101986, both inAnyCollection and hasAnyTag evaluate to false when using variables. presentmentCurrencyRate is 1.0. The metafield returns the expected JSON string.

Control test: When the same IDs and tags are hard-coded directly in the query arguments, both checks return true.

Notes: Code snippets and the exact GraphQL structure are central to the issue. No consensus or workaround is provided yet.

Status: Unresolved; the author asks what is wrong with the variable-based approach and why it differs from hard-coded arguments.

<div class="post-metadata">

**Author:** ![IvanPro](https://avatars.discourse-cdn.com/v4/letter/i/2acd7d/32.png) [@IvanPro](https://community.shopify.com/u/IvanPro)\
**Post date:** [June 10, 2024, 8:58pm UTC](https://community.shopify.com/t/shopify-function-input-query-value/330528/1 "2024-06-10T20:58:34Z")

</div>

I am trying to use values inside shopify discount function but seems it is not working.

This is my graphql

```auto
query RunInput($selectedCollectionIds: [ID!], $tags: [String!]) {
  discountNode {
    metafield(namespace: "some-product-discounts", key: "function-configuration") {
      value
    }
  }
  cart {
    lines {
      quantity
      merchandise {
        ...on ProductVariant {
            id
            product {
              inAnyCollection(ids: $selectedCollectionIds)
              hasAnyTag(tags: $tags)
              id
            }
        }
      }
      promotionId: attribute (key: "_FOKKIO_shop_surprise_promotion_id") {
        value
      },
      cost {
        amountPerQuantity {
          amount
          currencyCode
        }
        totalAmount {
          amount
          currencyCode
        }
      }
    }
  }
  presentmentCurrencyRate

}

```

I have the next result

```auto
{
  "discountNode": {
    "metafield": {
      "value": "{\"selectedCollectionIds\":[\"gid://shopify/Collection/471875060002\"],\"tags\":[\"hero\"]}"
    }
  },
  "cart": {
    "lines": [
      {
        "quantity": 1,
        "merchandise": {
          "id": "gid://shopify/ProductVariant/43712112689442",
          "product": {
            "inAnyCollection": false,
            "hasAnyTag": false,
            "id": "gid://shopify/Product/7984435101986"
          }
        },
        "promotionId": null,
        "cost": {
          "amountPerQuantity": {
            "amount": "69.99",
            "currencyCode": "USD"
          },
          "totalAmount": {
            "amount": "69.99",
            "currencyCode": "USD"
          }
        }
      }
    ]
  },
  "presentmentCurrencyRate": "1.0"
}

```

```javascript
"inAnyCollection": false,
"hasAnyTag": false,

```

but they are suposed to be true. Both of them.  
When I don’t use input variables and just pass the values

```css
inAnyCollection(ids: ["gid://shopify/Collection/471875060002"])
hasAnyTag(tags: ["hero"])

```

the are true.

What am I douing wrong?
