Skip to content

Conversation

@RosoPenaranda
Copy link

IMPORTANT: Please do not create a Pull Request without creating an issue first.

Fixed issues (PRs without this will not be accepted)

Changes

  • Create Role Module (resolver, services, guards, decorator, entity)
  • Integrate Role Module with User module ( add role to user, remove role to user, create user with default role)
  • Add seeders in seeders.services

PR Checklist

  • Does your PR contain relevant tests that pass?
  • [ X] Is your code linted? yarn lint or yarn lint:fix
  • [ X] Does your code build correctly in ALL projects? yarn build

@codecov
Copy link

codecov bot commented Jul 29, 2020

Codecov Report

Merging #287 into develop will decrease coverage by 4.50%.
The diff coverage is 51.48%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #287      +/-   ##
===========================================
- Coverage    83.05%   78.55%   -4.51%     
===========================================
  Files           71       79       +8     
  Lines         1216     1413     +197     
  Branches        60       74      +14     
===========================================
+ Hits          1010     1110     +100     
- Misses         186      283      +97     
  Partials        20       20              
Flag Coverage Δ
#unittests 78.55% <51.48%> (-4.51%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
packages/api/src/Auth/index.ts 100.00% <ø> (ø)
packages/api/src/Role/Role.service.ts 12.24% <12.24%> (ø)
packages/api/src/User/User.service.ts 38.77% <16.66%> (-61.23%) ⬇️
packages/api/src/Role/guards/Role.guard.ts 29.41% <29.41%> (ø)
packages/api/src/Role/pipe/Role-validation.pipe.ts 50.00% <50.00%> (ø)
packages/api/src/User/User.resolver.ts 92.10% <75.00%> (-4.67%) ⬇️
packages/api/src/Role/Role.resolver.ts 81.48% <81.48%> (ø)
packages/api/src/User/User.entity.ts 97.91% <92.85%> (-2.09%) ⬇️
packages/api/src/App.module.ts 100.00% <100.00%> (ø)
packages/api/src/Database/index.ts 100.00% <100.00%> (ø)
... and 14 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d5fb984...6bbaa5b. Read the comment docs.

@ghost ghost self-requested a review August 2, 2020 19:21
* Protect a query or mutation by specific roles. Also implemments GQLAuthGuard
* @param roles List of RoleType's to auth a query/mutation/etc
*/
export const Roles = (...roles: (keyof typeof RoleType)[]) => applyDecorators(
Copy link

Choose a reason for hiding this comment

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

The standard seems to be that decorators are defined in their own file.

E.g.

Can this be moved to a roles.decorator.ts file?

*/
export const Roles = (...roles: (keyof typeof RoleType)[]) => applyDecorators(
SetMetadata('roles', roles),
UseGuards(GQLAuthGuard, RoleGuard)
Copy link

Choose a reason for hiding this comment

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

NestJS documentation related to creating a roles decorator doesn't use UseGuard in their example.

Can you explain the need for UseGuards(GQLAuthGuard, RoleGuard) here?

@ghost ghost self-requested a review August 2, 2020 20:09
Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

  • Test check failed and will need to be fixed before merge
  • No unit tests added for this new feature; what is your plan for adding unit tests?

@ghost
Copy link

ghost commented Aug 14, 2020

Hey @RosoPenaranda how's it going with this one?

@ghost ghost added the project:api Task for the back-end API label Aug 23, 2020
@tristanMatthias
Copy link
Contributor

I'm going to take over this one tonight, as it's over a month old

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

project:api Task for the back-end API

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Role Module

4 participants