[B2BTEAM-3748] Request priceToken on the product query (Pricing Fallback V2) - #199
Open
wender wants to merge 1 commit into
Open
[B2BTEAM-3748] Request priceToken on the product query (Pricing Fallback V2)#199wender wants to merge 1 commit into
wender wants to merge 1 commit into
Conversation
Pricing Fallback V2: expose the signed price returned by the search on the product query, so the apps that read the product context can forward it as `priceToken` on add to cart and Checkout can close the cart while the Pricing is unavailable. The field is added through a separate opt-in `PriceTokenFragment` instead of `CommertialOfferFragment`, because that fragment is also spread into `recommendationShelf.gql`, whose provider `vtex.recommendation-graphql` declares its own `Offer` type without the field - adding it there would invalidate that document on every account. Each query now opts in, so no existing consumer changes and no other provider is asked for a field it cannot resolve. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Contributor
|
Hi! I'm VTEX IO CI/CD Bot and I'll be helping you to publish your app! 🤖 Please select which version do you want to release:
And then you just need to merge your PR when you are ready! There is no need to create a release commit/tag.
|
|
Beep boop 🤖 I noticed you didn't make any changes at the
In order to keep track, I'll create an issue if you decide now is not a good time
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is the purpose of this pull request?
Request the signed price (
priceToken) on the product query, so that the apps which read the product context can forward it on add to cart.react/fragments/priceToken.graphql→fragment PriceTokenFragment on Offer { priceToken }react/queries/product.gqlspreads it insidesellers { commertialOffer { … } }CHANGELOG.mdentry underUnreleasedThe field is not added to
CommertialOfferFragment, and that is the whole design of this PR — see below.What problem is this solving?
Pricing Fallback V2 (B2BTEAM-3748, reference Slack thread): Intelligent Search now signs the price of each offer, and a storefront that forwards that signed price on add to cart lets the platform keep closing carts while the Pricing system is down. Portal already does this; Store Framework and FastStore are the remaining consumers (FastStore shipped it in 4.5.0).
This app is the first hop of the Store Framework chain:
vtex.store/react/ProductContext.jsconsumesvtex.store-resources/QueryProduct, so whatever this query does not request never reachesvtex.product-context— and therefore never reaches any storefront app that wants to forward the token. It is item 1 of the activity list Wisney Cardeal mapped in the thread ("propagate priceToken in the store-resources queries").Dependencies, so it is clear where this sits:
intschprice signingvtex.search-resolver@1.106.0/vtex.search-graphql@0.72.0priceTokenresolvable herevtex.store-resourcesvtex.checkout-graphql(ItemInput.priceToken)vtex.add-to-cart-button,vtex.minicart,vtex.store-components(SF); sku-list#17, quickorder#185 (B2B Suite)We are not the owners of this app — this comes from the B2B side, which hit the gap while implementing the B2B Suite part, and is offered as a ready starting point rather than something to merge as is. It should not be merged before
checkout-graphqlaccepts the field, otherwise any consumer that starts forwarding the token breaks its own add to cart.Why a separate opt-in fragment instead of
CommertialOfferFragment: that fragment is spread into 8 queries, and one of them —recommendationShelf.gql— resolves through@context(provider: "vtex.recommendation-graphql"), which declares its ownOffertype:It has every field the shared fragment asks for and no
priceToken, so adding the field there would make that document invalid against that provider. With an opt-in fragment, each query asks for the token only where its provider can resolve it, and nothing else in the app changes.Scope kept deliberately small. Only
product.gqlopts in, because that is what feedsvtex.product-contextand what the add-to-cart flows read. The other search-backed queries (productSearchV2/V3,products,productSuggestions,sponsoredProducts,productRecommendations) can opt in with a one-line spread when their consumers need it — we left them out on purpose, since the token is ~450 bytes per seller and shelf/search responses would grow (and get cached) for consumers that do not use it yet.kitItemswas left out for the same reason.How should this be manually tested?
Requires an account with price signing enabled on Intelligent Search (still behind a feature flag; the search team enables it on request) and
search-graphql@0.72.0or newer.vtex linkthis app and run the product query for any SKU —items[].sellers[].commertialOffer.priceTokenshould come back populated.priceToken: null(the field exists in the schema, the value is simply absent).Validated on
b2bstoreqa/ workspacepricetoken, with this app linked next tovtex.checkout-graphql(patched) andvtex.sku-list: the token reachedvtex.product-context, the SKU list forwarded it onaddToCart, and the cart was closed normally. Before thecheckout-graphqlchange, the same flow failed withField "priceToken" is not defined by type ItemInput— which is exactly why the two PRs have to land in that order.Screenshots or example usage
Product query response on
b2bstoreqawith the patched fragment (token truncated):{ "sellerId": "1", "commertialOffer": { "Price": 599, "priceToken": "eyJhbGciOiJFUzI1NiIsImtpZCI6IjZkYTc3YzQ4…" } }Decoded claims — bound to the SKU, seller, price and sales channel of that very offer, valid for 30 minutes:
{ "price": 59900, "priceWithoutDiscount": 59900, "seller": "1", "id": "77777000", "accountName": "b2bstoreqa", "salesChannel": "1" }Types of changes