-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GraphQL mutations refactoring: input types, cart mutations & multi-cart preparation #18
Conversation
…unt, removeCartProduct, updateCartItemQuantity
…es react-dropzone to 9
…es react-dropzone to 9 2/2
…dPassword with Input suffix
17331ff
to
4d72972
Compare
i would be cautious with confusing orders with carts. That it is the same is just a technical detail of your implementation, but for a user, its fundamentally different. I can't just update the quantity of an order after it has been payed. so so i would suggest:
Also concerning mutations that actually should be able to update an order (because of backoffice-jobs):
or also for product manage functions
The api should focus first on a developer who implements the shop frontend and second on a developer implementing backoffice apps. Altough unchained has a good acl implementation, its hard to reason about what can be done by whom, just looking at the graphql api |
So let's review all the order/cart related mutations in this branch: addCartProduct addOrderProduct Today, only confirmOrder, payOrder and removeOrder are actual methods that should be allowed when the order is not a cart anymore. Following your argumentation, we would stick with Cart as the name for all the other mutations and take an optional cartId for all mutations above that currently require an orderId, resulting in: addCartProduct(cartId: ID, ...) removeOrder Currently the difference between updateOrder and updateCart is that cart mutations initiate a new cart when there is no cart available for the user/country combination. But for mutations like removeCartDiscount or removeCartItem initiating a new cart does not make that much sense. prefixing with mutations.manage is not a good idea due to graphql/graphql-js#221 (comment) |
updateOrder is definitely missleading in the new naming |
The more I think about it I guess we should definetly make the user know that a cart is an open order. But the updateCart namings are much more elegant. What about having something like: I mean the GraphQL type that gets returned is an Order too, having that link is not only a technical implementation detail but also an important knowhow of the whole concept. Then they know that cart's _id stays persistent throughout the checkout for example. And I think it could be pretty straightforward to document that lifecycle. |
So I would go for this set of mutations: addCartProduct(orderId: ID, ...) removeOrder(orderId: ID!, ...) Maybe we could argue that a payment provider and a delivery provider might change again even after you did the checkout, for example if you selected invoice as payment during checkout but after the consumer changes his mind and wants to pay directly with CC. In that case we would promote those functions and require explicit orderId's: setOrderPaymentProvider(orderId: ID!, ...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The more I think about it I guess we should definetly make the user know that a cart is an open order. But the updateCart namings are much more elegant.
What about having something like:
addCartProduct(orderId: ID, ...)I mean the GraphQL type that gets returned is an Order too, having that link is not only a technical implementation detail but also an important knowhow of the whole concept. Then they know that cart's _id stays persistent throughout the checkout for example. And I think it could be pretty straightforward to document that lifecycle.
i agree on that, I also realized that as well. I think the mix of updateCartXXX and orderId makes sense after all, it makes you understand the conecpt better.
yeah. Ok so maybe have a clear description on these methods? |
…nt and renames various order mutations
Thanks @macrozone for the review, please see the updated issue comment about the final schema changes. |
GraphQL mutations refactoring: input types, cart mutations & multi-cart preparation
This PR contains massive name refactorings / api surface changes.
Removed (BREAKING):
Renamed (BREAKING):
New order manipulating mutation parameters in preparation of "multi-cart":
New convenience mutations:
That way, a very simple checkout is possible without fetching the orderId once in one big query but the full feature set is only available when using the indirect methods.