Class: Mutations::Notes::Create::Base

Inherits:
Base
  • Object
show all
Defined in:
app/graphql/mutations/notes/create/base.rb

Overview

This is a Base class for the Note creation Mutations and is not mounted as a GraphQL mutation itself.

Direct Known Subclasses

DiffNote, ImageDiffNote, Note

Constant Summary

Constants inherited from BaseMutation

BaseMutation::ERROR_MESSAGE

Instance Method Summary collapse

Methods inherited from BaseMutation

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

Instance Method Details

#resolve(args) ⇒ Object


26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'app/graphql/mutations/notes/create/base.rb', line 26

def resolve(args)
  noteable = authorized_find!(id: args[:noteable_id])

  check_object_is_noteable!(noteable)

  note = ::Notes::CreateService.new(
    noteable.project,
    current_user,
    create_note_params(noteable, args)
  ).execute

  {
    note: (note if note.persisted?),
    errors: errors_on_object(note)
  }
end