Content Graph: Can orderBy on nested Variants.Price.Amount be scoped to the filtered Variants?

Hi Optimizely Team,

I’m trying to implement market-scoped price sorting using Optimizely Content Graph and have run into an issue where orderBy on a nested field does not appear to respect the filter applied to the nested array.

Scenario

We have a GenericProduct type with a nested Variants array. Each element in the array represents one purchasable variant of a product and carries its own Market, Price, and AvailableInventory values.

Simplified schema:

type GenericProduct {
  Code: String
  Name: String
  Status: String
  Variants: [VariantModel]
}

type VariantModel {
  Code: String
  Market: String        # e.g. "US-WHOLESALE", "CA-WHOLESALE"
  Price: MoneyModel
  AvailableInventory: Int
  WarehouseCode: String
}

type MoneyModel {
  Amount: Float
  Currency: String
}

Sample documents:

[
  {
    "Code": "PROD-A",
    "Name": "iPhone 14 128GB",
    "Variants": [
      {
        "Code": "VAR-A1",
        "Market": "US-WHOLESALE",
        "Price": { "Amount": 450.00 },
        "AvailableInventory": 10
      },
      {
        "Code": "VAR-A2",
        "Market": "CA-WHOLESALE",
        "Price": { "Amount": 390.00 },
        "AvailableInventory": 5
      }
    ]
  },
  {
    "Code": "PROD-B",
    "Name": "Samsung Galaxy S23",
    "Variants": [
      {
        "Code": "VAR-B1",
        "Market": "US-WHOLESALE",
        "Price": { "Amount": 420.00 },
        "AvailableInventory": 8
      }
    ]
  },
  {
    "Code": "PROD-C",
    "Name": "Google Pixel 7",
    "Variants": [
      {
        "Code": "VAR-C1",
        "Market": "US-WHOLESALE",
        "Price": { "Amount": 380.00 },
        "AvailableInventory": 3
      },
      {
        "Code": "VAR-C2",
        "Market": "CA-WHOLESALE",
        "Price": { "Amount": 310.00 },
        "AvailableInventory": 2
      }
    ]
  }
]

The Query

A user authenticated to US-WHOLESALE only searches for products and requests results sorted by Starting Price ascending:

GenericProduct(
  where: {
    Status: { eq: "Published" }
    Variants: {
      Market: { in: ["US-WHOLESALE"] }
    }
  }
  orderBy: {
    Variants: {
      Price: {
        Amount: ASC
      }
    }
  }
  limit: 20
) {
  items {
    Code
    Name
    Variants {
      Market
      Price { Amount }
    }
  }
}

Problem Statement

The where clause correctly restricts which products appear — only products that have at least one Variants entry satisfying Market = US-WHOLESALE are returned. This works correctly.

When orderBy: { Variants: { Price: { Amount: ASC } } } is applied, we expect the sort to use only the variant(s) that also satisfy the market filter — i.e., the minimum price across US-WHOLESALE variants only.

Expected sort order for the US-WHOLESALE user

Product US-WHOLESALE Price Expected Rank
PROD-C (Pixel 7) $380.00 1st
PROD-B (Galaxy S23) $420.00 2nd
PROD-A (iPhone 14) $450.00 3rd

What actually happens

The orderBy on the nested field is not scoped to the market filter. Content Graph evaluates the sort using the minimum price across all nested Variants regardless of market, including variants the user cannot access.

Product All-variant minimum Actual sort rank
PROD-C (Pixel 7) $310.00 (CA-WHOLESALE) 1st
PROD-A (iPhone 14) $390.00 (CA-WHOLESALE) 2nd
PROD-B (Galaxy S23) $420.00 (US-WHOLESALE) 3rd

The displayed Starting Price for PROD-A (after client-side market filtering) is $450.00, but it ranks 2nd — above PROD-B at $420.00. The sort order is incorrect for the user's accessible market.

Request / Question

Is there a planned or existing mechanism in Content Graph's GQL orderBy syntax to apply a filter on the nested path used for sorting?

If not, is there a recommended pattern for market-scoped price sorting on a GenericProduct type with a nested variants array, without fetching all documents client-side?

Environment

Optimizely CMS: 12
Optimizely Commerce: 14

Content Graph packages:

<PackageReference Include="Optimizely.ContentGraph.Cms" Version="4.3.1" />
<PackageReference Include="Optimizely.Graph.Commerce" Version="1.3.2" />

Thanks in advance for any guidance on the supported query syntax, limitations of nested sorting, or recommended approach for this scenario.

#343285
Sep 11, 2026 13:42
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.