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 Edit Role API Endpoint #37

Merged
merged 5 commits into from
Mar 14, 2024
Merged

Conversation

shencynthia
Copy link
Contributor

@shencynthia shencynthia commented Mar 8, 2024

Notion Ticket Link

Create Edit Role API

Implementation Description

  • Added a new service to update a user's role by their ID - only accessible by admins
  • Added a resolver for the service

Steps to Test

  1. Navigate to the GraphQL playground: localhost:8080/graphql
  2. Login using this mutation:
mutation Login($email: String!, $password: String!) {
  login(email: $email, password: $password) {
    accessToken
    id
  }
}

Query variables:

{
  "email": "<[email protected]"",
  "password": "<yourpassword>"
}
  1. From the MongoDB Console, ensure the account that you are logged in with has the role "Admin", if not you can change it in the console.
  2. Open a new tab to run the updateUserRole mutation:
mutation UpdateUserRole($id: ID!, $role: Role!) {
  updateUserRole(id: $id, role: $role)
}

Query variables:

{
  "id": "<your id (from the login mutation)>",
  "role": "Volunteer"
}

HTTP Headers:
Link for access_token value

{
	"authorization": "bearer  <access token (from the login mutation)>",
	"access_token": "<from the notion link above"
}
  1. The output should be "updateUserRole": null since it's a void function. If you try running the query again it will not work since your role should now be Volunteer. Also, can also check that it updated in the MongoDB console.

Checklist

  • My PR name is descriptive and in imperative tense
  • My commit messages are descriptive and in imperative tense. My commits are atomic and trivial commits are squashed or fixup'd into non-trivial commits
  • I have run the appropriate linter(s)
  • I have requested a review from the PL, as well as other devs who have background knowledge on this PR or who will be building on top of this PR

Linting & Formatting

Mac

docker exec -it CWC-backend /bin/bash -c "yarn fix"
docker exec -it CWC-frontend /bin/bash -c "yarn fix"

Windows

docker exec -it CWC-backend bash -c "yarn fix"
docker exec -it CWC-frontend bash -c "yarn fix"

@achandrabalan achandrabalan self-requested a review March 11, 2024 00:30
@SohailSayed SohailSayed self-requested a review March 11, 2024 00:40
@owen-sellner owen-sellner self-requested a review March 11, 2024 00:53
Copy link
Contributor

@achandrabalan achandrabalan left a comment

Choose a reason for hiding this comment

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

LOCKEDDD IN !!
LGTM

Copy link
Contributor

@carolynzhang18 carolynzhang18 left a comment

Choose a reason for hiding this comment

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

🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥

@shencynthia shencynthia merged commit 430a65f into main Mar 14, 2024
1 check passed
@shencynthia shencynthia deleted the cynthia-sohail/create-edit-role-api branch March 14, 2024 21:31
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.

3 participants