Skip to content
This repository has been archived by the owner on Sep 21, 2022. It is now read-only.

Allow inviteShopMember to accept multiple groups #10

Merged

Conversation

loan-laux
Copy link
Contributor

@loan-laux loan-laux commented Apr 30, 2020

Resolves #9
Impact: breaking
Type: feature

Test with api-plugin-email-templates#7

Issue

The inviteShopMember mutation allows a groupId to be specified, but it would be even better to allow multiple groups with a groupIds array.

Solution

Allow inviteShopMember to take a groupIds array instead of a groupId string.

Breaking changes

  • The groupId variable won't work anymore for inviteShopMember. To invite a new user to a single account, pass a single-item groupIds array to the mutation.
  • The inviteNewShopMember template needs to be at its latest version, as the groupName variable was updated to groupNames.

Testing

  1. Call inviteShopMember with one group in the groupIds array.
  2. Receive an e-mail referring to this group's name in a singular form.
  3. Verify that, for this invite's object in the AccountInvites collection, the groupIds field has the correct value.
  4. Sign up as the new account. Verify that the account is part of the expected group.
  5. Call inviteShopMember with multiple groups in the groupIds array.
  6. Receive an e-mail referring to the group names in a plural form.
  7. Verify that, for this invite's object in the AccountInvites collection, the groupIds field has the correct value.
  8. Sign up as the new account. Verify that the account is part of the expected groups.

@loan-laux loan-laux marked this pull request as draft April 30, 2020 10:46
@loan-laux loan-laux marked this pull request as ready for review April 30, 2020 11:09
Copy link
Member

@kieckhafer kieckhafer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the idea behind this makes sense, and the code overall looks good.

As this is really the first breaking change in any of our new plugins, I think we need to at least discuss a process for this.

Some thoughts:

  • We could just make a clean break and call this 2.0 right now. If this is the case, we'll need a new commit with the BREAKING CHANGE trigger for semantic-release
  • We could keep groupId as a deprecated field for now, and simply add groupIds and encourage everyone to use that instead, until we make a breaking change later on.
  • When we update Reaction to include the new version of this plugin, how do we call out there has been a breaking change? Or do we even need to do that anymore?

cc @aldeed

@loan-laux
Copy link
Contributor Author

@kieckhafer I like the idea of keeping groupId but as a deprecated field for now. I'll let you guys discuss the rest. Happy to make changes as needed.

@aldeed
Copy link
Contributor

aldeed commented May 1, 2020

@loan-laux @kieckhafer If we pull breaking plugin changes into Reaction's stock API project, we'll need a major release for it. While we don't want to be shy of major releases, we do want to try to keep them to a minimum. The general idea is to always deprecate rather than remove, and every so often, when it's time for a major release, we'll remove everything that is currently deprecated.

So yes, groupId should remain with @deprecated directive added. It should be easy in either the resolver or the internal fn to set groupIds = [groupId]. If they pass in both, it should throw an error.

@kieckhafer
Copy link
Member

@aldeed makes sense. should we come up with some standard of tracking breaking releases across all these repos, so that when we do want to make a major Reaction release, we have some standard way of knowing which of the plugins we can update? Perhaps a ticket with at BREAKING tag on it in each repo? Or do we make an EPIC ticket in Reaction that tracks all of the changes across the projects?

@loan-laux
Copy link
Contributor Author

@aldeed Unfortunately, it looks like the @deprecated directive isn't allowed yet on input fields, but the GraphQL team's working on it. As for the payload, we're simply returning an Account so there's nowhere to use this directive there. Thoughts?

loan-laux and others added 15 commits May 2, 2020 18:59
Signed-off-by: Erik Kieckhafer <[email protected]>
Signed-off-by: Loan Laux <[email protected]>
@loan-laux loan-laux force-pushed the outgrow-inviteShopMember-groupIds branch from 473c1aa to 1d23744 Compare May 2, 2020 17:00
@loan-laux loan-laux mentioned this pull request May 2, 2020
@loan-laux
Copy link
Contributor Author

Sorry for the mixup here. I actually had PR #8 merged into this branch. I've rebased it so that it's only changes related to this PR.

@aldeed
Copy link
Contributor

aldeed commented May 5, 2020

@loan-laux Now that you remind me, we came across that issue before and solved it just with DEPRECATED in description. You can follow the pattern here: https://github.com/reactioncommerce/api-plugin-pricing-simple/blob/trunk/src/schemas/schema.graphql#L113-L114

The important thing is that we can run a search for "deprecated" text across all plugins when we're ready to do a breaking release and delete stuff.

@loan-laux
Copy link
Contributor Author

@aldeed I figured that out and wrote "Deprecated" in the field description but it isn't all-caps. Should I update it to DEPRECATED or is it okay as-is?

@loan-laux
Copy link
Contributor Author

Nevermind, I realized that the pattern you mentioned also had a use otherField instead part which was missing in my schema. I've replicated it.

@kieckhafer kieckhafer requested a review from aldeed May 9, 2020 05:39
Copy link
Contributor

@aldeed aldeed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inline comments

src/mutations/inviteShopMember.js Outdated Show resolved Hide resolved
src/mutations/inviteShopMember.js Outdated Show resolved Hide resolved
src/mutations/inviteShopMember.js Show resolved Hide resolved
src/mutations/inviteShopMember.js Show resolved Hide resolved
src/resolvers/Mutation/inviteShopMember.js Show resolved Hide resolved
src/mutations/createAccount.js Outdated Show resolved Hide resolved
@loan-laux loan-laux mentioned this pull request May 26, 2020
@loan-laux
Copy link
Contributor Author

@aldeed Implemented all of your requests here. Group IDs in createAccount are now listed in a Set instead of an Array, to natively ensure that there are no duplicates.

@aldeed aldeed merged commit 7c993f0 into reactioncommerce:trunk Jun 2, 2020
@rc-publisher
Copy link
Collaborator

🎉 This PR is included in version 1.4.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@rc-publisher rc-publisher added the released Applied automatically by semantic-release label Jun 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
released Applied automatically by semantic-release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow a groupIds array as input of inviteShopMember
4 participants