This repository was archived by the owner on Sep 21, 2022. It is now read-only.
Removed hardcoded Fulfillment type in createProduct & applied allowedValues (Jira MCOSS-51) #49
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.
Signed-off-by: Sujith mail.sujithvn@gmail.com
Resolves #MCOSS-51
Impact: breaking
Type: feature
Issue
Currently there is no restriction on the allowed values used for supported fulfillment types and it accepts any string. We would want to restrict the input values only to the allowed values defined by the installed plugins.
Additionally, new product is created with "shipping" as the supportedFulfillmentType. Going forward it has to be dependent on the installed fulfillment type plugins and 'shipping' may not be one of the installed plugin.
Solution
As part of the implementation of the Fulfillment feature we are restricting the allowed values for the fulfillment type to only those that are defined in the shop via new plugins.
The list of allowed fulfillment types are retrieved by the query
allFulfillmentTypesand this dynamic list is updated in the schema viaSchema.extendimplemented in theStartupfunction.Addionally,
createProductwill not have 'shipping' as the default value for supportedFulfillmentTypes. It is replaced by user provided values (if any) or empty array.Breaking changes
Product schema is updated with dynamic 'allowedValue' for the field
supportedFulfillmentTypes. Any values other than the ones present in the list returned by the query will throw a schema validation error.Testing
createProductmutation andupdateProductmutations with different input values for supportedFulfillmentTypes. Both gave expected results. Only installed plugins (fulfillment-type) were allowed as input values.