Class: Types::MergeRequestType
- Inherits:
-
BaseObject
- Object
- GraphQL::Schema::Object
- BaseObject
- Types::MergeRequestType
show all
- Defined in:
- app/graphql/types/merge_request_type.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from BaseObject
accepts, assignable?, authorization, authorize, authorized?, #current_user, #id
#present, #unpresented
Class Method Details
.authorization_scopes ⇒ Object
15
16
17
|
# File 'app/graphql/types/merge_request_type.rb', line 15
def self.authorization_scopes
super + [:ai_workflows]
end
|
Instance Method Details
#available_auto_merge_strategies ⇒ Object
350
351
352
|
# File 'app/graphql/types/merge_request_type.rb', line 350
def available_auto_merge_strategies
AutoMergeService.new(object.project, current_user).available_strategies(object)
end
|
#closed_at ⇒ Object
354
355
356
|
# File 'app/graphql/types/merge_request_type.rb', line 354
def closed_at
object.metrics&.latest_closed_at
end
|
#commits ⇒ Object
358
359
360
361
362
|
# File 'app/graphql/types/merge_request_type.rb', line 358
def commits
object.commits(
load_from_gitaly: true
).commits
end
|
#commits_without_merge_commits ⇒ Object
364
365
366
367
368
|
# File 'app/graphql/types/merge_request_type.rb', line 364
def commits_without_merge_commits
object.commits(
load_from_gitaly: true
).without_merge_commits
end
|
#committers ⇒ Object
This is temporary to fix a bug where committers is already loaded and memoized and calling it again with a certain GraphQL query can cause the Rails to to throw a ActiveRecord::UnmodifiableRelation error
389
390
391
392
393
394
395
|
# File 'app/graphql/types/merge_request_type.rb', line 389
def committers
if Feature.enabled?(:load_commits_from_gitaly_in_graphql, object.project)
object.commits(load_from_gitaly: true).committers
else
object.commits.committers
end
end
|
#default_merge_commit_message ⇒ Object
342
343
344
|
# File 'app/graphql/types/merge_request_type.rb', line 342
def default_merge_commit_message
object.default_merge_commit_message(include_description: false, user: current_user)
end
|
#default_squash_commit_message ⇒ Object
346
347
348
|
# File 'app/graphql/types/merge_request_type.rb', line 346
def default_squash_commit_message
object.default_squash_commit_message(user: current_user)
end
|
#detailed_merge_status ⇒ Object
#diff_stats(path: nil) ⇒ Object
320
321
322
323
324
325
326
327
328
|
# File 'app/graphql/types/merge_request_type.rb', line 320
def diff_stats(path: nil)
stats = Array.wrap(object.diff_stats&.to_a)
if path.present?
stats.select { |s| s.path == path }
else
stats
end
end
|
#diff_stats_summary ⇒ Object
#discussion_locked ⇒ Object
338
339
340
|
# File 'app/graphql/types/merge_request_type.rb', line 338
def discussion_locked
!!object.discussion_locked
end
|
#merge_after ⇒ Object
378
379
380
|
# File 'app/graphql/types/merge_request_type.rb', line 378
def merge_after
object.merge_schedule&.merge_after
end
|
#merge_user ⇒ Object
374
375
376
|
# File 'app/graphql/types/merge_request_type.rb', line 374
def merge_user
object.metrics&.merged_by || object.merge_user
end
|
#notes_count_for_collection(key) ⇒ Object
409
410
411
412
413
414
415
416
417
418
419
420
421
422
|
# File 'app/graphql/types/merge_request_type.rb', line 409
def notes_count_for_collection(key)
BatchLoader::GraphQL.for(object.id).batch(key: key) do |ids, loader, _args|
counts = Note.count_for_collection(
ids,
'MergeRequest',
'COUNT(DISTINCT discussion_id) as count'
)
counts = yield(counts).index_by(&:noteable_id)
ids.each do |id|
loader.call(id, counts[id]&.count || 0)
end
end
end
|
#pipeline_creation_requests ⇒ Object
424
425
426
|
# File 'app/graphql/types/merge_request_type.rb', line 424
def pipeline_creation_requests
::Ci::PipelineCreation::Requests.for_merge_request(object)
end
|
#resolvable_discussions_count ⇒ Object
401
402
403
|
# File 'app/graphql/types/merge_request_type.rb', line 401
def resolvable_discussions_count
notes_count_for_collection(:merge_request_resolvable_discussions_count, &:resolvable)
end
|
#resolved_discussions_count ⇒ Object
405
406
407
|
# File 'app/graphql/types/merge_request_type.rb', line 405
def resolved_discussions_count
notes_count_for_collection(:merge_request_resolved_discussions_count, &:resolved)
end
|
#security_auto_fix ⇒ Object
370
371
372
|
# File 'app/graphql/types/merge_request_type.rb', line 370
def security_auto_fix
object.author == ::Users::Internal.in_organization(object.project.organization).security_bot
end
|
#source_branch_protected ⇒ Object
334
335
336
|
# File 'app/graphql/types/merge_request_type.rb', line 334
def source_branch_protected
object.source_project.present? && ProtectedBranch.protected?(object.source_project, object.source_branch)
end
|
#web_path ⇒ Object
397
398
399
|
# File 'app/graphql/types/merge_request_type.rb', line 397
def web_path
::Gitlab::Routing.url_helpers.project_merge_request_path(object.project, object)
end
|