debian-mirror-gitlab/app/graphql/mutations/notes/update/base.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

49 lines
1.3 KiB
Ruby
Raw Normal View History

2020-03-13 15:44:24 +05:30
# frozen_string_literal: true
module Mutations
module Notes
module Update
# This is a Base class for the Note update mutations and is not
# mounted as a GraphQL mutation itself.
class Base < Mutations::Notes::Base
authorize :admin_note
argument :id,
2021-04-17 20:07:23 +05:30
::Types::GlobalIDType[::Note],
required: true,
2021-10-27 15:23:28 +05:30
description: 'Global ID of the note to update.'
2020-03-13 15:44:24 +05:30
def resolve(args)
note = authorized_find!(id: args[:id])
pre_update_checks!(note, args)
updated_note = ::Notes::UpdateService.new(
note.project,
current_user,
note_params(note, args)
).execute(note)
# It's possible for updated_note to be `nil`, in the situation
# where the note is deleted within `Notes::UpdateService` due to
# the body of the note only containing Quick Actions.
{
note: updated_note&.reset,
errors: updated_note ? errors_on_object(updated_note) : []
}
end
private
def pre_update_checks!(_note, _args)
raise NotImplementedError
end
def note_params(_note, args)
2020-10-24 23:57:45 +05:30
{ note: args[:body], confidential: args[:confidential] }.compact
2020-03-13 15:44:24 +05:30
end
end
end
end
end