forked from fs/task_tracker_itis_2023
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'fs:master' into master
- Loading branch information
Showing
33 changed files
with
262 additions
and
25 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 |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
|
||
# Ignore bundler config. | ||
/.bundle | ||
/vendor | ||
|
||
# Ignore all logfiles and tempfiles. | ||
/log/* | ||
|
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
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,15 @@ | ||
module Mutations | ||
class DestroyComment < BaseMutation | ||
argument :id, ID, required: true | ||
|
||
type Types::Payloads::CommentPayload | ||
|
||
def resolve(id:) | ||
comment = Comment.find(id) | ||
|
||
result = Comments::Destroy.call(comment: comment) | ||
|
||
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,14 @@ | ||
module Mutations | ||
class DestroyProject < BaseMutation | ||
argument :id, ID, required: true | ||
|
||
type Types::Payloads::ProjectPayload | ||
|
||
def resolve(id:) | ||
project = Project.find(id) | ||
|
||
result = ::Projects::Destroy.call(project: project) | ||
result.to_h.merge(errors: formatted_errors(result.project)) | ||
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,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 |
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,16 @@ | ||
module Mutations | ||
class DestroyUser < BaseMutation | ||
argument :id, ID, required: true | ||
|
||
type Types::Payloads::UserPayload | ||
|
||
def resolve(**options) | ||
user = ::User.find(options[:id]) | ||
authorize! user, to: :destroy? | ||
|
||
result = Users::Destroy.call(user: user) | ||
|
||
result.to_h.merge(errors: formatted_errors(result.user)) | ||
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,18 @@ | ||
module Mutations | ||
class UpdateTask < BaseMutation | ||
argument :input, Types::Inputs::UpdateTaskInput, required: true | ||
|
||
type Types::Payloads::TaskPayload | ||
|
||
def resolve(input:) | ||
input_hash = input.to_h | ||
|
||
result = ::Tasks::Update.call( | ||
task: Task.find_by(id: input_hash.delete(:id)), | ||
task_params: input_hash, user: current_user | ||
) | ||
|
||
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,13 @@ | ||
module Mutations | ||
class UpdateUser < BaseMutation | ||
argument :input, Types::Inputs::UpdateUserInput | ||
|
||
type Types::Payloads::UpdateUserPayload | ||
|
||
def resolve(input:) | ||
result = Users::Update.call(user_params: input.to_h, user: current_user) | ||
|
||
result.to_h.merge(errors: formatted_errors(result.user)) | ||
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,10 @@ | ||
module Resolvers | ||
class Comment < Resolvers::Base | ||
argument :id, ID, required: true | ||
type Types::CommentType, null: true | ||
|
||
def resolve(**args) | ||
::Comment.find_by(id: args[:id]) | ||
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,9 @@ | ||
module Resolvers | ||
class Comments < Resolvers::Base | ||
type [Types::CommentType], null: true | ||
|
||
def resolve(**_args) | ||
::Comment.all | ||
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 |
---|---|---|
@@ -1,10 +1,11 @@ | ||
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 | ||
field :user_id, Integer, null: false | ||
field :user, UserType, null: false | ||
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: true | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module Types | ||
module Inputs | ||
class UpdateTaskInput < Types::BaseInputObject | ||
argument :id, ID, required: true | ||
argument :name, String, required: true | ||
argument :description, String, required: false | ||
argument :status, TaskStatusType, required: false | ||
argument :deadline_at, GraphQL::Types::ISO8601DateTime, 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module Types | ||
module Inputs | ||
class UpdateUserInput < Types::BaseInputObject | ||
argument :first_name, String, required: false | ||
argument :last_name, String, required: false | ||
argument :email, String, required: false | ||
argument :role, UserRoleType, 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,21 @@ | ||
# frozen_string_literal: true | ||
|
||
module Types | ||
class MutationType < Types::BaseObject | ||
field :sign_up, mutation: Mutations::SignUp | ||
field :sign_in, mutation: Mutations::SignIn | ||
|
||
field :create_project, mutation: Mutations::CreateProject | ||
field :update_project, mutation: Mutations::UpdateProject | ||
field :destroy_project, mutation: Mutations::DestroyProject | ||
|
||
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 | ||
field :destroy_comment, mutation: Mutations::DestroyComment | ||
|
||
field :update_user, mutation: Mutations::UpdateUser | ||
field :destroy_user, mutation: Mutations::DestroyUser | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module Types | ||
module Payloads | ||
class TaskPayload < Types::BaseObject | ||
field :task, TaskType, null: true | ||
field :errors, [Types::UserError], null: 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 Payloads | ||
class UpdateUserPayload < Types::BaseObject | ||
field :user, UserType, null: false | ||
field :errors, [Types::UserError], null: 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module Types | ||
module Payloads | ||
class UserPayload < Types::BaseObject | ||
field :user, UserType, null: true | ||
field :errors, [Types::UserError], null: 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module Users | ||
class Destroy | ||
include Interactor | ||
|
||
delegate :user, to: :context | ||
|
||
def call | ||
user.destroy | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module Users | ||
class Update | ||
include Interactor::Organizer | ||
|
||
organize Users::Save | ||
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
Oops, something went wrong.