impact-graph
impact-graph copied to clipboard
endpoint for users to delete a project in draft status from DB
Related to https://github.com/Giveth/giveth-dapps-v2/issues/1271 - Users should be able to delete a project they own in draft status from the DB.
We will need an endpoint for the front-end to call to trigger this action in our DB
@divine-comedian pls add priority
@Reshzera Please take this issue, it's a straight forward issue and will help you to get more familiar with impact-graph.
You should implement a new endpoint in projectResolver for deleting draft projects from DB, and create a ProjectStatusHistory
type to add a record on that for this purpose to can keep track of this activity
Please write test cases for below scenarios ( and if there is any scenario that I forgot to mention it, please implement them
- [x] Success scenario, project owner should can delete his/her project
- [x] Project owner should not be able to delete a project with non-draft status, especially write test cases for active (statusId : 5)
- [x] User should not be able to delete someone else's project
- [x] When deleting projects delete all related stuffs to the project like
project_address
,project_verification_form
,project_udpate
if exist - [ ] Make sure it creates a record in
ProjectStatusHistory
table
PS If you had any questions from me, feel free to ask it here or DM me
I've implemented the deleteDraftProject
mutation. Please note that the endpoint for this mutation is now available. To call it, use the following mutation query:
mutation ($projectId: Float!) {
deleteDraftProject(projectId: $projectId)
}
Make sure to pass the projectId
as a Float
in the mutation variables.
Logic Overview:
-
User Authentication: The mutation ensures that the user attempting to delete the draft project is authenticated by retrieving the currently logged-in user.
-
Project Existence: It checks whether the project with the provided
projectId
exists in the system. If the project does not exist, an error is thrown indicating that the project could not be found. -
Ownership Verification: The mutation verifies that the authenticated user is the owner of the project. If the user is not the owner (i.e., their user ID does not match the
adminUserId
of the project), an error is thrown to prevent unauthorized deletion. -
Draft Status Check: The mutation ensures that only projects with a status of
drafted
can be deleted. If the project is not in the draft status, an error is thrown indicating that only drafted projects can be deleted.
However, note that a ProjectStatusHistory record will not be created because, as I talked to @mohammadranjbarz the project will be deleted from the database, there won't be a projectId to reference for this record.
@Reshzera - since you moved this to QA is there a way for the QA to test this? if so can you please share any endpoint links or resources they might need
@divine-comedian I spoke with @mohammadranjbarz and I don't think there is an easy way to test this issue, so I'll tag the FE guys and wait they integrate this endpoint, so QA can test this in FE. In this case, is there a correct status for this issue?
sure thing @Reshzera - please update here once the FE issue is approved.