2018-12-05 23:21:45 +05:30
# frozen_string_literal: true
2018-11-08 19:23:39 +05:30
module Types
class MergeRequestType < BaseObject
2019-07-07 11:18:12 +05:30
graphql_name 'MergeRequest'
2019-09-04 21:01:54 +05:30
implements ( Types :: Notes :: NoteableType )
2019-07-07 11:18:12 +05:30
authorize :read_merge_request
2018-11-08 19:23:39 +05:30
expose_permissions Types :: PermissionTypes :: MergeRequest
present_using MergeRequestPresenter
2019-12-04 20:38:33 +05:30
field :id , GraphQL :: ID_TYPE , null : false # rubocop:disable Graphql/Descriptions
field :iid , GraphQL :: STRING_TYPE , null : false # rubocop:disable Graphql/Descriptions
field :title , GraphQL :: STRING_TYPE , null : false # rubocop:disable Graphql/Descriptions
2019-09-30 21:07:59 +05:30
markdown_field :title_html , null : true
2019-12-04 20:38:33 +05:30
field :description , GraphQL :: STRING_TYPE , null : true # rubocop:disable Graphql/Descriptions
2019-09-30 21:07:59 +05:30
markdown_field :description_html , null : true
2019-12-04 20:38:33 +05:30
field :state , MergeRequestStateEnum , null : false # rubocop:disable Graphql/Descriptions
field :created_at , Types :: TimeType , null : false # rubocop:disable Graphql/Descriptions
field :updated_at , Types :: TimeType , null : false # rubocop:disable Graphql/Descriptions
field :source_project , Types :: ProjectType , null : true # rubocop:disable Graphql/Descriptions
field :target_project , Types :: ProjectType , null : false # rubocop:disable Graphql/Descriptions
field :diff_refs , Types :: DiffRefsType , null : true # rubocop:disable Graphql/Descriptions
2018-11-08 19:23:39 +05:30
# Alias for target_project
2019-12-04 20:38:33 +05:30
field :project , Types :: ProjectType , null : false # rubocop:disable Graphql/Descriptions
field :project_id , GraphQL :: INT_TYPE , null : false , method : :target_project_id # rubocop:disable Graphql/Descriptions
field :source_project_id , GraphQL :: INT_TYPE , null : true # rubocop:disable Graphql/Descriptions
field :target_project_id , GraphQL :: INT_TYPE , null : false # rubocop:disable Graphql/Descriptions
field :source_branch , GraphQL :: STRING_TYPE , null : false # rubocop:disable Graphql/Descriptions
field :target_branch , GraphQL :: STRING_TYPE , null : false # rubocop:disable Graphql/Descriptions
field :work_in_progress , GraphQL :: BOOLEAN_TYPE , method : :work_in_progress? , null : false # rubocop:disable Graphql/Descriptions
field :merge_when_pipeline_succeeds , GraphQL :: BOOLEAN_TYPE , null : true # rubocop:disable Graphql/Descriptions
field :diff_head_sha , GraphQL :: STRING_TYPE , null : true # rubocop:disable Graphql/Descriptions
field :merge_commit_sha , GraphQL :: STRING_TYPE , null : true # rubocop:disable Graphql/Descriptions
field :user_notes_count , GraphQL :: INT_TYPE , null : true # rubocop:disable Graphql/Descriptions
field :should_remove_source_branch , GraphQL :: BOOLEAN_TYPE , method : :should_remove_source_branch? , null : true # rubocop:disable Graphql/Descriptions
field :force_remove_source_branch , GraphQL :: BOOLEAN_TYPE , method : :force_remove_source_branch? , null : true # rubocop:disable Graphql/Descriptions
field :merge_status , GraphQL :: STRING_TYPE , null : true # rubocop:disable Graphql/Descriptions
field :in_progress_merge_commit_sha , GraphQL :: STRING_TYPE , null : true # rubocop:disable Graphql/Descriptions
field :merge_error , GraphQL :: STRING_TYPE , null : true # rubocop:disable Graphql/Descriptions
field :allow_collaboration , GraphQL :: BOOLEAN_TYPE , null : true # rubocop:disable Graphql/Descriptions
field :should_be_rebased , GraphQL :: BOOLEAN_TYPE , method : :should_be_rebased? , null : false # rubocop:disable Graphql/Descriptions
field :rebase_commit_sha , GraphQL :: STRING_TYPE , null : true # rubocop:disable Graphql/Descriptions
field :rebase_in_progress , GraphQL :: BOOLEAN_TYPE , method : :rebase_in_progress? , null : false , calls_gitaly : true # rubocop:disable Graphql/Descriptions
# rubocop:disable Graphql/Descriptions
2019-03-02 22:35:43 +05:30
field :merge_commit_message , GraphQL :: STRING_TYPE , method : :default_merge_commit_message , null : true , deprecation_reason : " Renamed to defaultMergeCommitMessage "
2019-12-04 20:38:33 +05:30
# rubocop:enable Graphql/Descriptions
field :default_merge_commit_message , GraphQL :: STRING_TYPE , null : true # rubocop:disable Graphql/Descriptions
field :merge_ongoing , GraphQL :: BOOLEAN_TYPE , method : :merge_ongoing? , null : false # rubocop:disable Graphql/Descriptions
field :source_branch_exists , GraphQL :: BOOLEAN_TYPE , method : :source_branch_exists? , null : false # rubocop:disable Graphql/Descriptions
field :mergeable_discussions_state , GraphQL :: BOOLEAN_TYPE , null : true # rubocop:disable Graphql/Descriptions
field :web_url , GraphQL :: STRING_TYPE , null : true # rubocop:disable Graphql/Descriptions
field :upvotes , GraphQL :: INT_TYPE , null : false # rubocop:disable Graphql/Descriptions
field :downvotes , GraphQL :: INT_TYPE , null : false # rubocop:disable Graphql/Descriptions
2018-11-08 19:23:39 +05:30
2019-12-04 20:38:33 +05:30
field :head_pipeline , Types :: Ci :: PipelineType , null : true , method : :actual_head_pipeline # rubocop:disable Graphql/Descriptions
field :pipelines , Types :: Ci :: PipelineType . connection_type , # rubocop:disable Graphql/Descriptions
2018-11-08 19:23:39 +05:30
resolver : Resolvers :: MergeRequestPipelinesResolver
2019-09-04 21:01:54 +05:30
2019-12-21 20:55:43 +05:30
field :milestone , Types :: MilestoneType , description : 'The milestone this merge request is linked to' ,
null : true ,
resolve : - > ( obj , _args , _ctx ) { Gitlab :: Graphql :: Loaders :: BatchModelLoader . new ( Milestone , obj . milestone_id ) . find }
field :assignees , Types :: UserType . connection_type , null : true , complexity : 5 , description : 'The list of assignees for the merge request'
field :participants , Types :: UserType . connection_type , null : true , complexity : 5 , description : 'The list of participants on the merge request'
field :subscribed , GraphQL :: BOOLEAN_TYPE , method : :subscribed? , null : false , complexity : 5 ,
description : 'Boolean flag for whether the currently logged in user is subscribed to this MR'
field :labels , Types :: LabelType . connection_type , null : true , complexity : 5 , description : 'The list of labels on the merge request'
field :discussion_locked , GraphQL :: BOOLEAN_TYPE , description : 'Boolean flag determining if comments on the merge request are locked to members only' ,
null : false ,
resolve : - > ( obj , _args , _ctx ) { ! ! obj . discussion_locked }
field :time_estimate , GraphQL :: INT_TYPE , null : false , description : 'The time estimate for the merge request'
field :total_time_spent , GraphQL :: INT_TYPE , null : false , description : 'Total time reported as spent on the merge request'
field :reference , GraphQL :: STRING_TYPE , null : false , method : :to_reference , description : 'Internal merge request reference. Returned in shortened format by default' do
argument :full , GraphQL :: BOOLEAN_TYPE , required : false , default_value : false , description : 'Boolean option specifying whether the reference should be returned in full'
end
2019-12-04 20:38:33 +05:30
field :task_completion_status , Types :: TaskCompletionStatus , null : false # rubocop:disable Graphql/Descriptions
2018-11-08 19:23:39 +05:30
end
end