Class: Types::Notes::NoteType

Inherits:
BaseObject
  • Object
show all
Includes:
ActionView::Helpers::SanitizeHelper
Defined in:
app/graphql/types/notes/note_type.rb

Instance Method Summary collapse

Methods inherited from BaseObject

accepts, assignable?, authorization, authorization_scopes, authorize, authorized?, #current_user

Methods included from Gitlab::Graphql::Present

#present, #unpresented

Instance Method Details

#idObject

We now support also SyntheticNote notes as a NoteType, but SyntheticNote does not have a real note ID, as SyntheticNote is generated dynamically from a ResourceEvent instance.



80
81
82
83
84
85
# File 'app/graphql/types/notes/note_type.rb', line 80

def id
  return super unless object.is_a?(SyntheticNote)

  # object is a presenter, so object.object returns the concrete note object.
  ::Gitlab::GlobalId.build(object, model_name: object.object.class.to_s, id: object.discussion_id)
end

#note_projectObject



87
88
89
# File 'app/graphql/types/notes/note_type.rb', line 87

def note_project
  object.project
end

#positionObject



91
92
93
# File 'app/graphql/types/notes/note_type.rb', line 91

def position
  object.position if object.position.is_a?(Gitlab::Diff::Position)
end

#projectObject



74
75
76
# File 'app/graphql/types/notes/note_type.rb', line 74

def project
  Gitlab::Graphql::Loaders::BatchModelLoader.new(Project, object.project_id).find
end

#system_note_icon_nameObject



70
71
72
# File 'app/graphql/types/notes/note_type.rb', line 70

def system_note_icon_name
  SystemNoteHelper.system_note_icon_name(object) if object.system?
end