Class: Mutations::MergeRequests::Create

Inherits:
BaseMutation
  • Object
show all
Includes:
ResolvesProject
Defined in:
app/graphql/mutations/merge_requests/create.rb

Constant Summary

Constants inherited from BaseMutation

BaseMutation::ERROR_MESSAGE

Instance Method Summary collapse

Methods included from ResolvesProject

#resolve_project

Methods inherited from BaseMutation

#api_user?, #current_user, #errors_on_object, #ready?

Instance Method Details

#resolve(project_path:, **attributes) ⇒ Object


41
42
43
44
45
46
47
48
49
50
51
# File 'app/graphql/mutations/merge_requests/create.rb', line 41

def resolve(project_path:, **attributes)
  project = authorized_find!(full_path: project_path)
  params = attributes.merge(author_id: current_user.id)

  merge_request = ::MergeRequests::CreateService.new(project, current_user, params).execute

  {
    merge_request: merge_request.valid? ? merge_request : nil,
    errors: errors_on_object(merge_request)
  }
end