Class: Types::Notes::NoteType

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

Instance Method Summary collapse

Methods inherited from BaseObject

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

Methods included from Gitlab::Graphql::Present

#present, #unpresented

Instance Method Details

#authorObject



112
113
114
# File 'app/graphql/types/notes/note_type.rb', line 112

def author
  Gitlab::Graphql::Loaders::BatchModelLoader.new(User, object.author_id).find
end

#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.



118
119
120
121
122
# File 'app/graphql/types/notes/note_type.rb', line 118

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

  ::Gitlab::GlobalId.build(object, model_name: object.class.to_s, id: object.discussion_id)
end

#projectObject



108
109
110
# File 'app/graphql/types/notes/note_type.rb', line 108

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

#system_note_icon_nameObject



104
105
106
# File 'app/graphql/types/notes/note_type.rb', line 104

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

#urlObject



100
101
102
# File 'app/graphql/types/notes/note_type.rb', line 100

def url
  ::Gitlab::UrlBuilder.build(object)
end