Skip to content

Commit

Permalink
Hw12 harb (#141)
Browse files Browse the repository at this point in the history
* Mutaions, project destroy added

* Mutations

Added mutations for creating and destroying the task
Note : Task destroy works if to disable the notifier part in the interactor -> yet to figure out

* Comments

Added comment type & comment\s resolvers

* Added the comment mutation-> Update

* Returned files in order

* Added empty lines to the end of each files

* Did the rest of the required edits

* Made the requested changes

* Solving some conflicts /organizing edits/

* fixes problems

* fixes 2

---------

Co-authored-by: deniszackharov <denis.zaharov@flatstack.com>
  • Loading branch information
Tomax47 and DenisZackharov committed Jan 9, 2024
1 parent 404ce4d commit 5b8e28b
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 16 deletions.
11 changes: 4 additions & 7 deletions app/graphql/mutations/destroy_project.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
module Mutations
class DestroyProject < BaseMutation
argument :input, Types::Inputs::DestroyProjectInput, required: true
argument :id, ID, required: true

type Types::Payloads::ProjectPayload

def resolve(input:)
input_params = input.to_h

result = Projects::Destroy.call(
project: Project.find(input_params.delete(:id))
)
def resolve(id:)
project = Project.find(id)

result = ::Projects::Destroy.call(project: project)
result.to_h.merge(errors: formatted_errors(result.project))
end
end
Expand Down
14 changes: 14 additions & 0 deletions app/graphql/mutations/destroy_task.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module Mutations
class DestroyTask < BaseMutation
argument :id, ID, required: true

type Types::Payloads::TaskPayload

def resolve(id:)
task = Task.find(id)

result = ::Tasks::Destroy.call(task: task, user: current_user)
result.to_h.merge(errors: formatted_errors(result.task))
end
end
end
2 changes: 1 addition & 1 deletion app/graphql/types/comment_type.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Types
class CommentType < Types::BaseObject
field :id, ID, null: false
field :content, String
field :content, String, null: false
field :created_at, GraphQL::Types::ISO8601DateTime, null: false
field :updated_at, GraphQL::Types::ISO8601DateTime, null: false
field :task, TaskType, null: false
Expand Down
2 changes: 1 addition & 1 deletion app/graphql/types/inputs/create_task_input.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module Inputs
class CreateTaskInput < Types::BaseInputObject
argument :project_id, ID, required: true
argument :name, String, required: true
argument :description, String, required: false
argument :description, String, required: true
argument :status, TaskStatusType, required: true
argument :deadline_at, GraphQL::Types::ISO8601DateTime, required: true
end
Expand Down
7 changes: 0 additions & 7 deletions app/graphql/types/inputs/destroy_project_input.rb

This file was deleted.

1 change: 1 addition & 0 deletions app/graphql/types/mutation_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class MutationType < Types::BaseObject

field :create_task, mutation: Mutations::CreateTask
field :update_task, mutation: Mutations::UpdateTask
field :destroy_task, mutation: Mutations::DestroyTask

field :create_comment, mutation: Mutations::CreateComment
field :update_comment, mutation: Mutations::UpdateComment
Expand Down

0 comments on commit 5b8e28b

Please sign in to comment.