2019-06-07 17:13:26 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Types
|
|
|
|
module Notes
|
|
|
|
class NoteType < BaseObject
|
|
|
|
graphql_name 'Note'
|
|
|
|
|
|
|
|
authorize :read_note
|
|
|
|
|
|
|
|
expose_permissions Types::PermissionTypes::Note
|
|
|
|
|
2020-06-01 00:08:25 +00:00
|
|
|
implements(Types::ResolvableInterface)
|
|
|
|
|
2021-01-20 15:10:29 +00:00
|
|
|
field :id, ::Types::GlobalIDType[::Note], null: false,
|
2021-02-05 15:09:28 +00:00
|
|
|
description: 'ID of the note.'
|
2019-06-07 17:13:26 +00:00
|
|
|
|
|
|
|
field :project, Types::ProjectType,
|
|
|
|
null: true,
|
2021-02-05 15:09:28 +00:00
|
|
|
description: 'Project associated with the note.'
|
2019-06-07 17:13:26 +00:00
|
|
|
|
|
|
|
field :author, Types::UserType,
|
|
|
|
null: false,
|
2021-02-05 15:09:28 +00:00
|
|
|
description: 'User who wrote this note.'
|
2019-06-07 17:13:26 +00:00
|
|
|
|
2021-07-22 09:08:22 +00:00
|
|
|
field :system, GraphQL::Types::Boolean,
|
2019-06-07 17:13:26 +00:00
|
|
|
null: false,
|
2021-02-05 15:09:28 +00:00
|
|
|
description: 'Indicates whether this note was created by the system or by a user.'
|
2021-07-22 09:08:22 +00:00
|
|
|
field :system_note_icon_name, GraphQL::Types::String, null: true,
|
2021-02-05 15:09:28 +00:00
|
|
|
description: 'Name of the icon corresponding to a system note.'
|
2019-06-07 17:13:26 +00:00
|
|
|
|
2021-07-22 09:08:22 +00:00
|
|
|
field :body, GraphQL::Types::String,
|
2019-06-07 17:13:26 +00:00
|
|
|
null: false,
|
|
|
|
method: :note,
|
2021-02-05 15:09:28 +00:00
|
|
|
description: 'Content of the note.'
|
2019-06-07 17:13:26 +00:00
|
|
|
|
2022-03-02 15:16:07 +00:00
|
|
|
field :confidential, GraphQL::Types::Boolean, null: true,
|
|
|
|
description: 'Indicates if this note is confidential.',
|
|
|
|
method: :confidential?
|
2019-12-16 00:07:33 +00:00
|
|
|
field :created_at, Types::TimeType, null: false,
|
2021-02-05 15:09:28 +00:00
|
|
|
description: 'Timestamp of the note creation.'
|
2019-12-16 00:07:33 +00:00
|
|
|
field :discussion, Types::Notes::DiscussionType, null: true,
|
2021-08-25 15:11:14 +00:00
|
|
|
description: 'Discussion this note is a part of.'
|
2019-12-16 00:07:33 +00:00
|
|
|
field :position, Types::Notes::DiffPositionType, null: true,
|
2021-08-25 15:11:14 +00:00
|
|
|
description: 'Position of this note on a diff.'
|
2022-03-02 15:16:07 +00:00
|
|
|
field :updated_at, Types::TimeType, null: false,
|
|
|
|
description: "Timestamp of the note's last activity."
|
2021-07-22 09:08:22 +00:00
|
|
|
field :url, GraphQL::Types::String,
|
2021-01-18 15:10:42 +00:00
|
|
|
null: true,
|
2021-02-05 15:09:28 +00:00
|
|
|
description: 'URL to view this Note in the Web UI.'
|
2021-01-18 15:10:42 +00:00
|
|
|
|
2021-12-17 15:13:39 +00:00
|
|
|
markdown_field :body_html, null: true, method: :note
|
|
|
|
|
2021-01-18 15:10:42 +00:00
|
|
|
def url
|
|
|
|
::Gitlab::UrlBuilder.build(object)
|
|
|
|
end
|
2020-07-08 15:09:24 +00:00
|
|
|
|
|
|
|
def system_note_icon_name
|
|
|
|
SystemNoteHelper.system_note_icon_name(object) if object.system?
|
|
|
|
end
|
2020-12-01 12:09:17 +00:00
|
|
|
|
|
|
|
def project
|
|
|
|
Gitlab::Graphql::Loaders::BatchModelLoader.new(Project, object.project_id).find
|
|
|
|
end
|
|
|
|
|
|
|
|
def author
|
|
|
|
Gitlab::Graphql::Loaders::BatchModelLoader.new(User, object.author_id).find
|
|
|
|
end
|
2019-06-07 17:13:26 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|