feat(simple-pricing): Compute displayPrice as resolver as needed #6025
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.
Impact: minor
Type: feature
Issue
With the existing simple-pricing core plugin flow,
catalogProduct.product.pricing.displayPrice
is computed at publication time (ahead of time) and stored in mongodb. For the in-development Catalog Publisher component, doing the computation ofdisplayPrice
at publish time would require the full set of currency formatting I18N data and logic to be available in kafka and kafka streams.Solution
Allow
displayPrice
to be computed at query time via a graphql resolver if necessary. This implementation works seamlessly with both the core simple-pricing plugin as before, but computesdisplayPrice
as needed if the catalog plugin is disabled in favor of the catalog publisher service in a particular deployment. No configuration is necessary and data could in theory even be mixed between catalog plugin and catalog publisher.Breaking changes
This should be fully compatible with existing clients and installations.
Testing
A unit test has been added. Manual testing is still planned/underway so I'll convert to ready for review when that is completed.
At the moment catalog publisher output data is arriving in the
Catalog2
collection in mongodb which is not used at all by reaction core or plugins. To test this we'd need to retarget or rename that so it's the realCatalog
collection. Undoubtedly the first time we do that some bugs will surface which we'll have to fix. Once those are fixed though, we should now be able to test this PR. If you query graphql with a query similar to below, and thedisplayPrice
attribute looks correct, this change is working properly.