Skip to content

Conversation

@Tharaae
Copy link
Contributor

@Tharaae Tharaae commented Dec 31, 2025

What/Why?

Changes in a product inventory does not reflect right away on product details page due GQL caching in Catalyst. To fix this issue, we will fetch the product/variant inventory data separately with no caching.

Testing

Screen record
https://github.com/user-attachments/assets/e060094d-c076-49c9-86e6-cc0797c1aac1

Migration

Rebase

@Tharaae Tharaae requested a review from a team as a code owner December 31, 2025 01:14
@changeset-bot
Copy link

changeset-bot bot commented Dec 31, 2025

🦋 Changeset detected

Latest commit: b329bc6

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@bigcommerce/catalyst-core Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link

vercel bot commented Dec 31, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
catalyst Ready Ready Preview, Comment Dec 31, 2025 1:21am
1 Skipped Deployment
Project Deployment Review Updated (UTC)
catalyst-uplift-vertex Ignored Ignored Dec 31, 2025 1:21am

Comment on lines +2 to +5
"@bigcommerce/catalyst-core": minor
---

Fetch product inventory data with a separate GQL query with no caching
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the rationale for marking this as a minor the impact it could have on performance and/or costs for the PDP?

This is the primary question that I have when introducing queries that aren't cached. Are we good with every single PDP load invoking the API? Are we certain merchants won't run into rate limits?

variables,
customerAccessToken,
fetchOptions: customerAccessToken ? { cache: 'no-store' } : { next: { revalidate } },
fetchOptions: { cache: 'no-store' },
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be removing caching from the existing query for product variants. Was this intentional? If the query is specifically for variant inventory quantities, can we update the query name to be explicit about that.

variables,
customerAccessToken,
fetchOptions: customerAccessToken ? { cache: 'no-store' } : { next: { revalidate } },
fetchOptions: { cache: 'no-store' },
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is no-store the appropriate value here or would a very small revalidation period be desirable? There's is always a chance for there to be stale inventory data, even if it's always fetched without caching since there could be race conditions when loading the page. This could be addressed with polling, but I question whether that's a good approach. Instead, a warning when stock is very low might be good enough to let the user know that the item product might be out of stock soon.

Comment on lines 135 to +136
const streamableProductVariant = Streamable.from(async () => {
const product = await streamableProduct;
const product = await streamableProductInventory;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the variable name change if this is specifically tracking product inventory?

Comment on lines 138 to 147
if (!product.inventory.hasVariantInventory) {
return undefined;
}

const variables = {
productId,
sku: product.sku,
};

const variants = await getStreamableProductVariant(variables, customerAccessToken);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the result here is coupled to both queries and we don't use getStreamableProductVariant elsewhere then we should combine this all into a single query so that we have all the data we need in a single query.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants