Skip to content
This repository was archived by the owner on Sep 21, 2022. It is now read-only.

Conversation

@sujithvn
Copy link

@sujithvn sujithvn commented Jul 7, 2022

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 allFulfillmentTypes and this dynamic list is updated in the schema via Schema.extend implemented in the Startup function.

Addionally, createProduct will 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

  1. Tested createProduct mutation and updateProduct mutations with different input values for supportedFulfillmentTypes. Both gave expected results. Only installed plugins (fulfillment-type) were allowed as input values.

sujithvn added 2 commits July 6, 2022 22:39
Signed-off-by: Sujith <mail.sujithvn@gmail.com>
Signed-off-by: Sujith <mail.sujithvn@gmail.com>
@sujithvn sujithvn requested a review from brent-hoover July 7, 2022 04:38
Signed-off-by: Sujith <mail.sujithvn@gmail.com>
@sujithvn sujithvn requested review from vanpho93 July 18, 2022 08:21
src/startup.js Outdated
* @returns {undefined}
*/
async function extendSchemas(context) {
let allFulfillmentTypesArray = await context.queries.allFulfillmentTypes(context);
Copy link
Member

Choose a reason for hiding this comment

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

I think we can add null check in here for "allFulfillmentTypes". If allFulfillmentTypes is undefined then set allFulfillmentTypesArray = [].

So it this would not be a breaking change.

Also I would prefer const allFulfillmentTypes = await context.queries.allFulfillmentTypes(context);

Signed-off-by: Sujith <mail.sujithvn@gmail.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants