Class: Mutations::Discussions::ToggleResolve

Inherits:
BaseMutation
  • Object
show all
Defined in:
app/graphql/mutations/discussions/toggle_resolve.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?, #raise_resource_not_available_error!

Instance Method Details

#resolve(id:, resolve:) ⇒ Object


25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'app/graphql/mutations/discussions/toggle_resolve.rb', line 25

def resolve(id:, resolve:)
  discussion = authorized_find_discussion!(id: id)
  errors = []

  begin
    if resolve
      resolve!(discussion)
    else
      unresolve!(discussion)
    end
  rescue ActiveRecord::RecordNotSaved
    errors << "Discussion failed to be #{'un' unless resolve}resolved"
  end

  {
    discussion: discussion,
    errors: errors
  }
end