reactioncommerce / api-plugin-carts

Carts plugin for the Reaction API
GNU General Public License v3.0
1 stars 14 forks source link

Cannot extend cart schema #16

Closed karaarda closed 2 years ago

karaarda commented 3 years ago

In the transformAndValidateCart mutation the cart schema is loaded directly from file as import { Cart as CartSchema } from "../simpleSchemas.js";. It makes it impossible to extend the cart schema as the validation fails. The schema should be retrieved from the context as follows: const CartSchema = context.simpleSchemas.Cart;

MohanNarayana commented 2 years ago

All validation is done against simpleSchema. The same schema is available via context. Any change in schema that has to be validated should be added/updated to simpleSchema.js

brent-hoover commented 2 years ago

@MohanNarayana what @karaarda is referring to is that our code is using the version of the schema directly imported from the original definition, not the version that gets extended which is available via the context, therefore even when properly extended schema validation will fail. I think they properly suggest the fix there which is to change the validation in the cart code to use the extended schema via the context. This should be best practice everywhere.

karaarda commented 2 years ago

It does not matter for me anymore to be honest.

brent-hoover commented 2 years ago

Is that because you are no longer using Open Commerce? Or you found another solution?

karaarda commented 2 years ago

The one I shared in the original post is a valid solution I think.

After trying to find someone to get in touch for a year without luck and finding ourselves re-writing or overriding almost everything, reaction commerce costed us a lot.

brent-hoover commented 2 years ago

@karaarda Would you be willing to talk to me about your experiences? https://discord.gg/aqnvYFZc

rc-publisher commented 2 years ago

:tada: This issue has been resolved in version 1.3.2 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

karaarda commented 2 years ago

@zenweasel joined the discord server but couldn't find you. feel free to find me in the server and text me