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

Add event trigger to deleteUser resolver #126

Merged

Conversation

rafael-marques
Copy link
Contributor

What problem is this solving?

Using Master Data V2, we don't have a trigger to run on "delete event" like in V1. This way we can't run scripts when deleting a user. Only on adding or updating. My motivation for this is to add the ability to run scripts after a delete action.

This modification will trigger an event sending a payload containing the is and email of the deleted user.
With this, we can add an event listener and run scripts needed for that scenario

How to test it?

To test, link this branch to a workspace. Then from another app, listen to an event called b2b-organizations-graphql.removeUser

Like this: service.json
image

Screenshots or example usage:

Screenshot 2023-09-15 at 12 00 11 PM

@vtex-io-ci-cd
Copy link

vtex-io-ci-cd bot commented Sep 15, 2023

Hi! I'm VTEX IO CI/CD Bot and I'll be helping you to publish your app! 🤖

Please select which version do you want to release:

  • Patch (backwards-compatible bug fixes)

  • Minor (backwards-compatible functionality)

  • Major (incompatible API changes)

And then you just need to merge your PR when you are ready! There is no need to create a release commit/tag.

  • No thanks, I would rather do it manually 😞

@vtex-io-docs-bot
Copy link

vtex-io-docs-bot bot commented Sep 15, 2023

Beep boop 🤖

I noticed you didn't make any changes at the docs/ folder

  • There's nothing new to document 🤔
  • I'll do it later 😞

In order to keep track, I'll create an issue if you decide now is not a good time

  • I just updated 🎉🎉

@github-actions
Copy link

github-actions bot commented Sep 18, 2023

Messages
📖 ❤️ Thanks!
📖

🎉 PR additions = 24, PR deletions = 6

Generated by 🚫 dangerJS against 6c9e80d

@albertm805 albertm805 requested review from albertm805 and removed request for mairatma September 18, 2023 16:10
node/resolvers/Mutations/Users.ts Outdated Show resolved Hide resolved
enzomerca
enzomerca previously approved these changes Sep 19, 2023
Copy link
Contributor

@enzomerca enzomerca left a comment

Choose a reason for hiding this comment

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

LGTM, just wondering if we should add such events to other actions as well (e.g. deleteCostCenter).

Just out of curiosity, what does your script do when an user is deleted @rafael-marques ?

@rafael-marques
Copy link
Contributor Author

Hey @enzomerca thanks for that. I believe applying that to other actions would be helpful.
Our script needs to delete the same user in a CRM we integrated with in order to sync the records, that's why we send the email in the payload.

@mairatma
Copy link
Contributor

mairatma commented Sep 19, 2023

Hey @enzomerca thanks for that. I believe applying that to other actions would be helpful. Our script needs to delete the same user in a CRM we integrated with in order to sync the records, that's why we send the email in the payload.

I agree that it can be useful, but let's avoid adding more events unless they're already necessary, ok? Otherwise we'll later be in trouble if we ever need to remove the events, afraid that someone might be using them.

mairatma
mairatma previously approved these changes Sep 19, 2023
Copy link
Contributor

@mairatma mairatma left a comment

Choose a reason for hiding this comment

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

Thanks, lgtm! Can you just rebase to fix conflicts with the master branch?

@rafael-marques
Copy link
Contributor Author

@mairatma looks like it's already up to date with master. Where are the conflicts?
image

@rafael-marques
Copy link
Contributor Author

Nvm, I've found it in the CHANGELOG and fixed it. Can you review again?

@mairatma
Copy link
Contributor

@polishq I always get this kind of problem on external PRs, where one of the checks fails complaining of the missing safe to test label. I add it, but the other check removes it before the failing one can verify that it was added... Do you know how to go around this?

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

warning The version of Java (11.0.17) you have used to run this analysis is deprecated and we will stop accepting it soon. Please update to at least Java 17.
Read more here

@polishq
Copy link
Contributor

polishq commented Sep 19, 2023

@polishq I always get this kind of problem on external PRs, where one of the checks fails complaining of the missing safe to test label. I add it, but the other check removes it before the failing one can verify that it was added... Do you know how to go around this?

@mairatma I believe it's behaving as intended. Adding the label triggers the actions to switch to the "pull_request_target" workflow (specifically for external contributions) instead of the normal "pull_request" workflow, and the label is automatically removed as part of that flow. That first security check is intended to remain "Failed" in this scenario, but the PR is still mergeable since it's not a required check.

Copy link
Contributor

@polishq polishq left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@albertm805 albertm805 left a comment

Choose a reason for hiding this comment

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

LGTM

@polishq polishq merged commit dce3ccd into vtex-apps:master Sep 19, 2023
@vtex-io-ci-cd
Copy link

vtex-io-ci-cd bot commented Sep 19, 2023

Your PR has been merged! App is being published. 🚀
Version 0.36.1 → 0.37.0

After the publishing process has been completed (check #vtex-io-releases) and doing A/B tests with the new version, you can deploy your release by running:

vtex deploy [email protected]

After that your app will be updated on all accounts.

For more information on the deployment process check the docs. 📖

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants