Repository navigation
feat(api): expose product clusters on product groups - #3499
Conversation
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: vtex/faststore/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: ⛔ Files ignored due to path filters (2)
📒 Files selected for processing (5)
Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review. WalkthroughThe VTEX search result model now types product clusters with string ChangesVTEX product clusters
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Change: Feature Merge Risk: ⚪ Minimal · up to The change exposes product clusters on product groups with an empty-list fallback when clusters are absent. No concrete merge-blocking issue is established; merge after normal build and test checks. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The change exposes additional catalog metadata through existing product retrieval, without adding a separate lookup or changing account selection. No control bypass was identified, but the public visibility policy for all returned cluster names and memberships was not independently established. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Hardening Proposals
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. |
| productClusters: Record<string, string> | ||
| clusterHighlights: ProductCluster[] | ||
| productClusters: ProductCluster[] | ||
| categories: string[] |
There was a problem hiding this comment.
[Functional.Interface] 🔴 BLOCK
clusterHighlights and productClusters were retyped from Record<string, string>/Record<string, any> to ProductCluster[], but VTEX's Catalog/Intelligent Search API returns these fields as an id→name map object (e.g. {"140": "Most Wanted"}), not an array of {id, name} objects. The type change does not reflect the real wire shape returned by the platform.
Action: Confirm the actual VTEX Search API response shape for productClusters/clusterHighlights (check a live response or VTEX docs). If it is still a Record<string,string>, keep the map type and transform it explicitly (e.g. Object.entries(raw).map(([id, name]) => ({ id, name }))) at the boundary instead of redeclaring the raw client type as an array.
To dismiss: reply /dk-review dismiss [reason] under this comment
There was a problem hiding this comment.
/dk-review dismiss Intelligent Search v1 returns productClusters and clusterHighlights as an array of { id, name }, not the Catalog API id-to-name map.
The OpenAPI schema (components.schemas.Product.properties) types both fields as array of { id: string, name: string }. The same shape is already in the FastStore fixtures (packages/api/test/mocks/AllProductsQuery.ts). The previous Record<string, string> type was stale. Catalog's map is a different API: this search client never receives it. Cross-selling only uses Catalog for product IDs, then hydrates the product through productsByIdentifier.
| root.isVariantOf.items.map((item) => enhanceSku(item, root.isVariantOf)), | ||
| productGroupID: ({ isVariantOf }) => isVariantOf.productId, | ||
| productClusters: ({ isVariantOf }) => isVariantOf.productClusters ?? [], | ||
| name: (root) => root.isVariantOf.productName, |
There was a problem hiding this comment.
[Functional.Check] 🟡 RESTRICT
The productClusters resolver passes isVariantOf.productClusters through unchanged (only defaulting to [] when nullish) and relies on it already matching the GraphQL StoreProductCluster[] shape. If the real VTEX response is an id→name map (as it historically has been for this field) rather than an array, this resolver returns a non-iterable object where GraphQL expects a list, which will throw a serialization error at query time instead of returning data.
Action: Add an explicit transformation step in the resolver that normalizes the raw VTEX payload into StoreProductCluster[] regardless of whether the source is a map or an array, and cover this with a test using a realistic raw fixture.
To dismiss: reply /dk-review dismiss [reason] under this comment
There was a problem hiding this comment.
/dk-review dismiss The resolver parent is already the Intelligent Search product, so productClusters arrives as { id, name }[]. A map-to-array transform would paper over a contract this client does not have.
isVariantOf.productClusters ?? [] only substitutes an empty list when the field is missing, which matches the non-null GraphQL type [StoreProductCluster!]!. isVariantOf itself is always the enhanced SKU (isVariantOf: (root) => root), so a null-parent case is not a real payload.
DK Review — Audit SummaryVerdict: ❌ BLOCKED
Only BLOCK and RESTRICT findings anchored to a changed line are commented inline on the diff. The other finding below opens no review thread. Scenarios evaluated: feature-flags, general-review, quality-ratchet 📋 Findings (3)BLOCK
RESTRICT
SUGGEST
DK Review v1.0.0 | To dismiss a finding: reply |
Checking only that productClusters exists would still pass if the field type changed.
@faststore/api
@faststore/cli
@faststore/components
@faststore/core
@faststore/diagnostics
@faststore/lighthouse
@faststore/sdk
@faststore/ui
commit: |
| productClusters: Record<string, string> | ||
| clusterHighlights: ProductCluster[] | ||
| productClusters: ProductCluster[] | ||
| categories: string[] |
There was a problem hiding this comment.
[Functional.Interface] 🔴 BLOCK
productClusters was changed from Record<string, string> (an ID→name map, as returned by the VTEX search client) to ProductCluster[] with no parsing/mapping code added anywhere in this diff. The new resolver productGroup.ts (isVariantOf.productClusters ?? []) just passes the raw value straight through, assuming it is already an array of {id, name} objects. If the actual VTEX Intelligent Search payload still comes back as an object map (which is what the prior type declared), GraphQL will fail trying to iterate a non-iterable object for the [StoreProductCluster!]! field, or silently serialize garbage.
Action: Confirm the real VTEX Search API response shape for productClusters. If it is still a map, add an explicit Object.entries(...) transformation into {id, name}[] in the client/resolver, and add a unit test that uses the real (map) fixture shape rather than one that already matches the target GraphQL type.
To dismiss: reply /dk-review dismiss [reason] under this comment
| clusterHighlights: Record<string, any> | ||
| productClusters: Record<string, string> | ||
| clusterHighlights: ProductCluster[] | ||
| productClusters: ProductCluster[] |
There was a problem hiding this comment.
[Functional.Interface] 🟡 RESTRICT
clusterHighlights was also retyped from Record<string, any> to ProductCluster[] in the same change, with no accompanying transformation logic and no consumer updated in this diff. This is the same unresolved shape mismatch as productClusters and will surface as a bug for any future/existing consumer of this field once type-checking is relied upon.
Action: Either revert this field's type until an actual consumer/transform is implemented, or verify and encode the real search-client response shape before merge.
To dismiss: reply /dk-review dismiss [reason] under this comment
|
eduardoformiga
left a comment
There was a problem hiding this comment.
Approving. One upgrade note, not a change request.
productClusters is new on StoreProductGroup (isVariantOf). That does not collide with the usual store extension, which adds the field on StoreProduct:
extend type StoreProduct {
productClusters: [IProductClusters!]
}Existing product { productClusters { id name } } queries keep using the store resolver. clusterHighlights is not added to the schema, so extend type StoreProductGroup { clusterHighlights } stays valid.
The case that fails faststore generate is a store that already has extend type StoreProductGroup { productClusters: SomeOtherType }. Schema merge throws Field "productClusters" already defined with a different type. In the stores checked (farewayqa, marinbrasil, devmarinbrasil), productClusters is on StoreProduct, and StoreProductGroup only extends specificationGroups and clusterHighlights. This was a sample, not every store.

0 New Issues
0 Fixed Issues
0 Accepted Issues
What's the purpose of this pull request?
VTEX Intelligent Search v1 returns
productClustersfor each catalog product, and the FastStore VTEX client already receives that data. However, the FastStore GraphQL schema does not expose it, so storefronts cannot read product-cluster membership on PDPs, product cards, or shelves without an API extension or an additional REST request.This restores access to product cluster IDs and names through the normalized FastStore product model.
How it works
StoreProductClusterwithidandname.productClusters: [StoreProductCluster!]!toStoreProductGroup, since VTEX product clusters belong to the catalog product rather than an individual SKU.StoreProductGroupresolver and returns an empty list when the field is absent.[{ id, name }]response shape.Storefront queries can request:
This is an additive GraphQL schema change.
How to test it?
pnpm --filter @faststore/api testpnpm --filter @faststore/api buildpnpm --filter @faststore/core gen-typespnpm exec biome check <changed files>References
Checklist
Summary by CodeRabbit