Skip to content

Item price range

Backend domain: app/graphql/items/ (ItemQueries, ItemService.get_item_price_range, ItemRepository.get_price_range) Migration: none — read-only query over the existing items.unit_price column.

Overview

itemPriceRange returns the minimum and maximum unitPrice across the visible item catalog so the frontend can bound a price-range filter/slider without fetching every item. It is a single aggregate query (MIN/MAX over items.unit_price) — no pagination, no per-row payload.

Archived items are excluded by default; pass includeArchived: true to widen the range over the whole catalog (matching the archived toggle on the items landing page).

GraphQL surface

Type

type ItemPriceRange {
  minPrice: Decimal
  maxPrice: Decimal
}

Both fields are nullable: when no items are in scope (empty catalog, or every item archived with includeArchived: false), minPrice and maxPrice are null. Render that as "no range available" rather than 0.

Query

itemPriceRange(includeArchived: Boolean! = false): ItemPriceRange!

The query result is always non-null; only its fields can be null.

Frontend contract

  • Call once when opening the items list / filter panel to seed the slider's min and max bounds.
  • includeArchived should mirror whatever archived toggle drives the list, so the slider bounds match the rows being filtered.
  • Treat null min/max as "no items" — disable the slider rather than defaulting to 0.
  • Decimal values come back as strings; parse before doing numeric comparisons.

Example:

query ItemPriceRange {
  itemPriceRange {
    minPrice
    maxPrice
  }
}