Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

GraphQL filter products by tags AND priceRange

GraphQL filter products by tags AND priceRange

codemonkey
Excursionist
12 1 2

I'm using the shopify-buy SDK and the fetchQuery function to issue the following payload:

first: 50
query: "tags:[new] AND priceRange:{minVariantPrice:0 AND maxVariantPrice:40}"
reverse: false
sortKey: "PRICE"

This is returning all products, and as far as I can tell the tags filter isn't working either. Where am I going wrong here? Here is the issued command:

fragment ProductFragment on Product {
  id
  availableForSale
  createdAt
  updatedAt
  descriptionHtml
  description
  handle
  productType
  title
  vendor
  publishedAt
  onlineStoreUrl
  options {
    id
    name
    values
  }
  images(first: 250) {
    pageInfo {
      hasNextPage
      hasPreviousPage
    }
    edges {
      cursor
      node {
        id
        src
        altText
      }
    }
  }
  variants(first: 250) {
    pageInfo {
      hasNextPage
      hasPreviousPage
    }
    edges {
      cursor
      node {
        ...VariantFragment
      }
    }
  }
}

fragment VariantFragment on ProductVariant {
  id
  title
  price
  priceV2 {
    amount
    currencyCode
  }
  presentmentPrices(first: 20) {
    pageInfo {
      hasNextPage
      hasPreviousPage
    }
    edges {
      node {
        price {
          amount
          currencyCode
        }
        compareAtPrice {
          amount
          currencyCode
        }
      }
    }
  }
  weight
  available: availableForSale
  sku
  compareAtPrice
  compareAtPriceV2 {
    amount
    currencyCode
  }
  image {
    id
    src: originalSrc
    altText
  }
  selectedOptions {
    name
    value
  }
  unitPrice {
    amount
    currencyCode
  }
  unitPriceMeasurement {
    measuredType
    quantityUnit
    quantityValue
    referenceUnit
    referenceValue
  }
}

query ($first: Int!, $query: String, $sortKey: ProductSortKeys, $reverse: Boolean) {
  products(first: $first, query: $query, sortKey: $sortKey, reverse: $reverse, after: "eyJsYXN0X2lkIjoxNTQzODk0MjM3MjM5LCJsYXN0X3ZhbHVlIjoiMTU0Mzg5NDIzNzIzOSJ9") {
    pageInfo {
      hasNextPage
      hasPreviousPage
    }
    edges {
      cursor
      node {
        ...ProductFragment
      }
    }
  }
}
Reply 1 (1)

harshparikh
Visitor
1 0 0

Try this:

tag : New