Class: Types::Notes::NoteType

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

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseObject

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

Methods included from Gitlab::Graphql::Present

#present, #unpresented

Class Method Details

.authorization_scopesObject



16
17
18
# File 'app/graphql/types/notes/note_type.rb', line 16

def self.authorization_scopes
  super + [:ai_workflows]
end

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.



92
93
94
95
96
97
# File 'app/graphql/types/notes/note_type.rb', line 92

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

#positionObject



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

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

#projectObject



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

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

#system_note_icon_nameObject



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

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