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.



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

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



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

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

#projectObject



77
78
79
# File 'app/graphql/types/notes/note_type.rb', line 77

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

#system_note_icon_nameObject



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

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