Skip to content
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

[Atwix]Make the destination_cart_id argument optional in the mergeCarts mutation #30469

Closed
magento-engcom-team opened this issue Oct 12, 2020 · 3 comments · Fixed by #30633
Assignees
Labels
Mageconf_Contribution_Day Priority: P1 Once P0 defects have been fixed, a defect having this priority is the next candidate for fixing. Progress: done Project: GraphQL
Milestone

Comments

@magento-engcom-team
Copy link
Contributor

magento-engcom-team commented Oct 12, 2020

Make the destination*cart*id argument optional in the mergeCarts mutation

Why

PR
#30633

This came up in a discussion with [@sirugh](https://github.com/sirugh] from the [pwa-studio|https://github.com/magento/pwa-studio) team.

When a user logs in (creates a new token), one of the first things the UI needs to do is merge the current guest cart (if items are present) into the customer account's cart.

If destination*cart*id is required, this requires 3 round trips:

  1. Call for Mutation.generateCustomerToken
  2. Call for Query.cart to get customer cart ID
  3. Call for Mutation.mergeCarts to merge guest cart ID into customer cart

Because a customer can only have a single cart, and this API only works for authenticated users, destination*cart*id is an unnecessary requirement here. If we make it optional, the login cart upgrade for UI can happen in a single request:

1. Mutations run serially, in-order. So `mergeCarts` will only execute
1. if `generateCustomerToken` succeeds
mutation LoginAndMergeCarts($email: String!, $password: String!, $guestCartID: String!) {
    generateCustomerToken(email: $email, password: $password) {
        token
    }
    mergeCarts(source*cart*id: $guestCartID) {
        ID
    }
} {code}
## Proposed Change

 
{code:java}
type Mutation {
-    mergeCarts(source*cart_id: String!, destination_cart*id: String!): Cart!
</ins>    mergeCarts(source*cart_id: String!, destination_cart*id: String): Cart!
} ```
<ins>**Approved Design**</ins>
 <https://github.com/magento/architecture/blob/mergeCarts-optional-destination/design-documents/graph-ql/coverage/mergeCarts-optional-destination.md> 
  
@magento-engcom-team magento-engcom-team added Priority: P1 Once P0 defects have been fixed, a defect having this priority is the next candidate for fixing. Progress: ready for dev labels Oct 12, 2020
@magento-engcom-team
Copy link
Contributor Author

The issue was exported from the internal JIRA. The link to the original JIRA issue: https://jira.corp.magento.com/browse/MC-37413

@m2-assistant
Copy link

m2-assistant bot commented Oct 12, 2020

Hi @magento-engcom-team. Thank you for your report.
To help us process this issue please make sure that you provided the following information:

  • Summary of the issue
  • Information on your environment
  • Steps to reproduce
  • Expected and actual results

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento give me 2.4-develop instance - upcoming 2.4.x release

For more details, please, review the Magento Contributor Assistant documentation.

Please, add a comment to assign the issue: @magento I am working on this


⚠️ According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.

🕙 You can find the schedule on the Magento Community Calendar page.

📞 The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, please join the Community Contributions Triage session to discuss the appropriate ticket.

🎥 You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel

✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

@magento-engcom-team magento-engcom-team changed the title Make the destination_cart_id argument optional in the mergeCarts mutation [Atwix]Make the destination_cart_id argument optional in the mergeCarts mutation Oct 12, 2020
@nrkapoor nrkapoor added this to the 2.4.2 milestone Oct 18, 2020
@andrewbess
Copy link
Contributor

@magento I am working on this

@ghost ghost added Progress: PR in progress and removed Progress: dev in progress Priority: P1 Once P0 defects have been fixed, a defect having this priority is the next candidate for fixing. labels Oct 24, 2020
@magento-engcom-team magento-engcom-team added Priority: P1 Once P0 defects have been fixed, a defect having this priority is the next candidate for fixing. Progress: done and removed Progress: PR in progress labels Oct 28, 2020
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Mageconf_Contribution_Day Priority: P1 Once P0 defects have been fixed, a defect having this priority is the next candidate for fixing. Progress: done Project: GraphQL
Projects
None yet
4 participants