Class: Mutations::MergeRequests::Create

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

Constant Summary

Constants inherited from BaseMutation

BaseMutation::ERROR_MESSAGE

Constants included from Gitlab::Graphql::Authorize::AuthorizeResource

Gitlab::Graphql::Authorize::AuthorizeResource::ConfigurationError, Gitlab::Graphql::Authorize::AuthorizeResource::RESOURCE_ACCESS_ERROR

Instance Method Summary collapse

Methods inherited from BaseMutation

#api_user?, authorization, authorized?, authorizes_object?, #current_user, #errors_on_object, #load_application_object, #ready?, #unauthorized_object

Methods included from Gitlab::Graphql::Authorize::AuthorizeResource

#authorize!, #authorized_find!, #authorized_resource?, #find_object, #raise_resource_not_available_error!

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!(project_path)
  params = attributes.merge(author_id: current_user.id)

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

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