-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HW12 [CreateTask, UpdateComment, DestroyProject] - Mutations (#144)
* CreateTask * add Destroy Project mutation * add mutation update commit * litte fixes * return removed mutations --------- Co-authored-by: deniszackharov <denis.zaharov@flatstack.com>
- Loading branch information
1 parent
dedba0a
commit 0c06541
Showing
7 changed files
with
62 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
module Mutations | ||
class CreateTask < BaseMutation | ||
argument :input, Types::Inputs::CreateTaskInput, required: true | ||
|
||
type Types::Payloads::TaskPayload | ||
|
||
def resolve(input:) | ||
input_params = input.to_h | ||
|
||
result = Tasks::Create.call( | ||
project: ::Project.find_by(id: input_params.delete(:project_id)), | ||
task_params: input_params | ||
) | ||
|
||
result.to_h.merge(errors: formatted_errors(result.task)) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
module Mutations | ||
class UpdateComment < BaseMutation | ||
argument :input, Types::Inputs::UpdateCommentInput, required: true | ||
|
||
type Types::Payloads::CommentPayload | ||
|
||
def resolve(input:) | ||
input_params = input.to_h | ||
|
||
result = Comments::Update.call( | ||
comment: Comment.find(input_params.delete(:id)), | ||
comment_params: input_params | ||
) | ||
|
||
result.to_h.merge(errors: formatted_errors(result.comment)) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module Types | ||
module Inputs | ||
class CreateTaskInput < Types::BaseInputObject | ||
argument :project_id, ID, required: true | ||
argument :name, String, required: true | ||
argument :description, String, required: false | ||
argument :status, TaskStatusType, required: true | ||
argument :deadline_at, GraphQL::Types::ISO8601DateTime, required: true | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module Types | ||
module Inputs | ||
class UpdateCommentInput < Types::BaseInputObject | ||
argument :id, ID, required: true | ||
argument :content, String, required: false | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters