GraphQL - Stock Grading (A/B/C) on productVariants Query

Hi,

Wondering how to retrieve the the inventory grading on variants view the query?

Thanks,

Chris

Hey @ChrisBradley - the A/B/C grading you’re seeing is most likely the ABC product analysis report. It assigns each variant a grade based on its share of revenue over the last 28 days, where A covers the variants accounting for the top 80% of revenue, B the next 15%, and C the final 5%. The ABC inventory analysis guide covers how that works.

That grade is a calculated report value, not a field stored on the variant. The ProductVariant object doesn’t expose it, so you can’t select it through productVariants, and no API field returns Shopify’s exact calculated grade.

If you need this programmatically, the closest path is to pull the underlying revenue with ShopifyQL and compute your own bands. The shopifyqlQuery query (requires the read_reports access scope) runs against the sales dataset.

query {
  shopifyqlQuery(query: "FROM sales SHOW gross_sales GROUP BY product_title, product_variant_title SINCE -28d UNTIL today ORDER BY gross_sales DESC") {
    tableData {
      columns { name dataType displayName }
      rows
    }
    parseErrors
  }
}

From those rows, sort by revenue, compute the cumulative share, and assign A up to 80% of total revenue, B to the next 15%, and C to the rest. The report’s measure is documented as retail price excluding discounts, with item cost excluded. The gross_sales field (sales before discounts and returns) is the closest ShopifyQL match, while total_sales includes tax and shipping and overstates relative to the report. This is a custom approximation, and it won’t necessarily match the in-Admin report exactly. Hope this helps!

@Donal-Shopify

Thanks, that makes sense.