-
Notifications
You must be signed in to change notification settings - Fork 154
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 cart error messages #291
Conversation
@@ -57,3 +59,8 @@ type CheckoutPaymentMethod { | |||
type CartGiftCard { | |||
code: String! | |||
} | |||
|
|||
type CartError { | |||
identifier: String |
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.
Please provide a use case when identifier
is needed on storefront.
It seems like it should not be exposed to storefront. If so than this CartError
type is excessive and its usages can be replaced with String
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 main reason to add the identifier is localizing part of process where errors were thrown. It should fetch profit for developers who extend base functionality and implements new features.
@@ -57,3 +59,8 @@ type CheckoutPaymentMethod { | |||
type CartGiftCard { | |||
code: String! | |||
} | |||
|
|||
type CartError { |
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.
Please explain in proposal why it is not possible to use built-in mechanism for GraphQL errors along with \Magento\Framework\Validation\ValidationException::getErrors
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 main reason that resolvers have conditions to prevent the execution of add product to cart and show items in the cart(example app/code/Magento/QuoteGraphQl/Model/Cart/AddProductsToCart.php). That behavior difference with frontend where the customer could see products in cart with messages on frontend but in graphql query he got the error.
@@ -57,3 +59,8 @@ type CheckoutPaymentMethod { | |||
type CartGiftCard { | |||
code: String! | |||
} | |||
|
|||
type CartError { |
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.
Please explain in the proposal why we should ignore other message types like success
, notice
, warning
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.
In base PR magento/graphql-ce#475 we expected all kind of messages. Looks like we need rename CartError to CartMessages.
|
||
type CartError { | ||
identifier: String | ||
text: String |
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.
text: String | |
text: String! |
@@ -57,3 +59,8 @@ type CheckoutPaymentMethod { | |||
type CartGiftCard { | |||
code: String! | |||
} | |||
|
|||
type CartError { | |||
identifier: String |
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.
identifier: String | |
identifier: String! |
@paliarush @XxXgeoXxX we have an alternative proposal here magento/graphql-ce#970 It will look like this:
Please let me know what do you think. |
Closing in favor of magento/graphql-ce#970 |
@lenaorobei it looks to me that there is a bug in the native error handling functionality which should be fixed. We should not introduce custom error messages. |
Problem
Now in GraphQL when multiple errors occur with cart there is no way to read all cart messages in order to understand the whole context.
Solution
@XxXgeoXxX proposes to add additional filed to the
Cart
type magento/graphql-ce#475Names changed by me but, PR will be adjusted once approved here.
Requested Reviewers
@paliarush