Solved

GraphQL - Price Rules - No value or value_type

querybuilderapp
Visitor
3 0 0

Hi all,

I would like to ask how I can get the value and value_type of a price rule over GraphQL.

When I take a look at REST API, the value and value_type have been returned

https://shopify.dev/docs/admin-api/rest/reference/discounts/pricerule#show-2021-01

querybuilderapp_0-1610535413887.png


But when I try to look up these values in GraphQL I have no clue where I can get the values.
There is no equivalent value_type and the "valueV2" gives me nothing.

 

querybuilderapp_1-1610535522797.png

Do you have any idea where I can the values from?

Thank you.

 

banned
Accepted Solution (1)

Gregarican
Shopify Partner
1033 86 285

This is an accepted solution.

Try this.

{
  priceRules(first: 5, reverse:true) {
    edges {
      node {
        id
        title
        status
        valueV2 {
          __typename
          ... on PricingPercentageValue {
            percentage
          }
          ... on MoneyV2 {
            amount
            currencyCode
          }
        }
      }
    }
  }
}

View solution in original post

Replies 2 (2)

Gregarican
Shopify Partner
1033 86 285

This is an accepted solution.

Try this.

{
  priceRules(first: 5, reverse:true) {
    edges {
      node {
        id
        title
        status
        valueV2 {
          __typename
          ... on PricingPercentageValue {
            percentage
          }
          ... on MoneyV2 {
            amount
            currencyCode
          }
        }
      }
    }
  }
}
querybuilderapp
Visitor
3 0 0

Thank you @Gregarican , I've learnt something new.

banned