Reference Twenty::GraphQL::Type constants as strings

This commit is contained in:
0x1eef 2024-04-08 17:37:27 -03:00
parent 89e3581912
commit 8804dad6bc
7 changed files with 10 additions and 16 deletions

View file

@ -1,9 +1,8 @@
# frozen_string_literal: true # frozen_string_literal: true
module Twenty::GraphQL module Twenty::GraphQL
require "graphql" require "graphql"
require_relative "graphql/input" require_relative "graphql/input"
require_relative "graphql/type"
require_relative "graphql/mutation" require_relative "graphql/mutation"
require_relative "graphql/type"
require_relative "graphql/schema" require_relative "graphql/schema"
end end

View file

@ -2,10 +2,9 @@
module Twenty::GraphQL::Input module Twenty::GraphQL::Input
class TaskInput < GraphQL::Schema::InputObject class TaskInput < GraphQL::Schema::InputObject
require_relative "../type/task_status"
argument :title, String, required: false argument :title, String, required: false
argument :content, String, required: false argument :content, String, required: false
argument :project_id, Int, required: false argument :project_id, Int, required: false
argument :status, Twenty::GraphQL::Type::TaskStatus, required: false argument :status, 'Twenty::GraphQL::Type::TaskStatus', required: false
end end
end end

View file

@ -3,5 +3,9 @@
module Twenty::GraphQL module Twenty::GraphQL
module Mutation module Mutation
require_relative "mutation/destroy_task" require_relative "mutation/destroy_task"
require_relative "mutation/complete_task"
require_relative "mutation/create_task"
require_relative "mutation/update_task"
require_relative "mutation/set_random_project_color"
end end
end end

View file

@ -2,11 +2,10 @@
module Twenty::GraphQL::Mutation module Twenty::GraphQL::Mutation
class SetRandomProjectColor < ::GraphQL::Schema::Mutation class SetRandomProjectColor < ::GraphQL::Schema::Mutation
require_relative "../type/project"
argument :project_id, Int, required: true argument :project_id, Int, required: true
field :errors, [String], null: false field :errors, [String], null: false
field :project, Twenty::GraphQL::Type::Project, null: true field :project, 'Twenty::GraphQL::Type::Project', null: true
def resolve(project_id:) def resolve(project_id:)
project = Twenty::Project.with_pk!(project_id) project = Twenty::Project.with_pk!(project_id)

View file

@ -2,11 +2,6 @@
module Twenty::GraphQL::Type module Twenty::GraphQL::Type
class Mutation < GraphQL::Schema::Object class Mutation < GraphQL::Schema::Object
require_relative "../mutation/destroy_task"
require_relative "../mutation/complete_task"
require_relative "../mutation/create_task"
require_relative "../mutation/update_task"
require_relative "../mutation/set_random_project_color"
field :destroy_task, mutation: Twenty::GraphQL::Mutation::DestroyTask field :destroy_task, mutation: Twenty::GraphQL::Mutation::DestroyTask
field :complete_task, mutation: Twenty::GraphQL::Mutation::CompleteTask field :complete_task, mutation: Twenty::GraphQL::Mutation::CompleteTask
field :create_task, mutation: Twenty::GraphQL::Mutation::CreateTask field :create_task, mutation: Twenty::GraphQL::Mutation::CreateTask

View file

@ -2,11 +2,10 @@
module Twenty::GraphQL::Type module Twenty::GraphQL::Type
class Project < GraphQL::Schema::Object class Project < GraphQL::Schema::Object
require_relative "task"
field :id, Int, null: false field :id, Int, null: false
field :name, String, null: false field :name, String, null: false
field :path, String, null: false field :path, String, null: false
field :color, String, null: false field :color, String, null: false
field :tasks, [Task], null: false field :tasks, '[Twenty::GraphQL::Type::Task]', null: false
end end
end end

View file

@ -2,12 +2,11 @@
module Twenty::GraphQL::Type module Twenty::GraphQL::Type
class Task < GraphQL::Schema::Object class Task < GraphQL::Schema::Object
require_relative "project"
field :id, Int, null: false field :id, Int, null: false
field :title, String, null: false field :title, String, null: false
field :status, TaskStatus, null: false field :status, 'Twenty::GraphQL::Type::TaskStatus', null: false
field :content, String, null: false field :content, String, null: false
field :project, Project, null: false field :project, 'Twenty::GraphQL::Type::Project', null: false
field :updated_at, GraphQL::Types::ISO8601DateTime, null: false field :updated_at, GraphQL::Types::ISO8601DateTime, null: false
field :is_ready, Boolean, null: false, method: :ready? field :is_ready, Boolean, null: false, method: :ready?
field :is_backlogged, Boolean, null: false, method: :backlog? field :is_backlogged, Boolean, null: false, method: :backlog?