summaryrefslogtreecommitdiff
path: root/app/graphql/types/issue_type.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/graphql/types/issue_type.rb')
-rw-r--r--app/graphql/types/issue_type.rb47
1 files changed, 47 insertions, 0 deletions
diff --git a/app/graphql/types/issue_type.rb b/app/graphql/types/issue_type.rb
new file mode 100644
index 00000000000..a8f2f7914a8
--- /dev/null
+++ b/app/graphql/types/issue_type.rb
@@ -0,0 +1,47 @@
+# frozen_string_literal: true
+
+module Types
+ class IssueType < BaseObject
+ expose_permissions Types::PermissionTypes::Issue
+
+ graphql_name 'Issue'
+
+ present_using IssuePresenter
+
+ field :iid, GraphQL::ID_TYPE, null: false
+ field :title, GraphQL::STRING_TYPE, null: false
+ field :description, GraphQL::STRING_TYPE, null: true
+ field :state, GraphQL::STRING_TYPE, null: false
+
+ field :author, Types::UserType,
+ null: false,
+ resolve: -> (obj, _args, _ctx) { Gitlab::Graphql::Loaders::BatchModelLoader.new(User, obj.author_id).find } do
+ authorize :read_user
+ end
+
+ field :assignees, Types::UserType.connection_type, null: true
+
+ field :labels, Types::LabelType.connection_type, null: true
+ field :milestone, Types::MilestoneType,
+ null: true,
+ resolve: -> (obj, _args, _ctx) { Gitlab::Graphql::Loaders::BatchModelLoader.new(Milestone, obj.milestone_id).find } do
+ authorize :read_milestone
+ end
+
+ field :due_date, Types::TimeType, null: true
+ field :confidential, GraphQL::BOOLEAN_TYPE, null: false
+ field :discussion_locked, GraphQL::BOOLEAN_TYPE,
+ null: false,
+ resolve: -> (obj, _args, _ctx) { !!obj.discussion_locked }
+
+ field :upvotes, GraphQL::INT_TYPE, null: false
+ field :downvotes, GraphQL::INT_TYPE, null: false
+ field :user_notes_count, GraphQL::INT_TYPE, null: false
+ field :web_url, GraphQL::STRING_TYPE, null: false
+
+ field :closed_at, Types::TimeType, null: true
+
+ field :created_at, Types::TimeType, null: false
+ field :updated_at, Types::TimeType, null: false
+ end
+end