Cart warnings
Cart warnings inform clients about automatic changes that a GraphQL mutation has made to a cart. Unlike a user error, which indicates a mutation failure, a warning confirms the mutation's success and the automatic changes it has made to the cart. All successful cart mutations can generate an array of CartWarning
objects. Each warning contains a discrete code, localized message and the ID of the targeted object in the cart. Clients can choose to address an automatic change, but action isn't required.
For example, if an item that was previously added to the cart becomes out of stock during the addition of another product, we'll issue a warning indicating MERCHANDISE_OUT_OF_STOCK
with the ID of the cart line for that out of stock item.
An example call to cartLinesAdd
is shown below.
Clients can take the target
from a warning and construct a call to CartLinesRemove
to remove an out of stock item.