-
Notifications
You must be signed in to change notification settings - Fork 69
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
feat(apollo): Create removeExercise resolver #2657
feat(apollo): Create removeExercise resolver #2657
Conversation
@flacial is attempting to deploy a commit to the c0d3-prod Team on Vercel. A member of the Team first needs to authorize it. |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Codecov Report
@@ Coverage Diff @@
## master #2657 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 189 189
Lines 3491 3504 +13
Branches 966 969 +3
=========================================
+ Hits 3491 3504 +13
|
This is out of the scope of this particular PR but related, maybe removed should be removedAt/removed_at as well like some other booleans we have changed to date | null before. |
I agree. It makes sense. |
Motivation
Currently, there is no way to set the removed flag on an exercise when an admin wants to remove it. The removed flag is a field in the database that indicates whether an exercise has been removed or not.
The PR is adding a resolver that will allow an admin to set the removed flag to true when they want to remove an exercise. This will mark the exercise as removed in the database, and it will no longer be visible to users.
Steps taken
removeExercise
removeExercise
resolver so it can be easily used in the client-sideindex.ts
with the new resolver and hooks.Unrelated steps
Resolver logic
id
.id
.id
of the user making the request (authorId
) from the request context (req).authorId
does not match theauthorId
of the exercise being removed, the resolver throws an error, indicating that the user is not authorized to remove the exercise.removedAt
andremovedById
fields to new Date & the user ID. It also includes the author and module relations in the update.Testing results
Executes
removeExercise
:Result:
Result if it's already removed:
Result if the exercise is not found:
Testing instructions
/api/graphql
Testing result
sectionRelated issues