diff options
Diffstat (limited to 'app/graphql/types/notes')
-rw-r--r-- | app/graphql/types/notes/note_type.rb | 94 | ||||
-rw-r--r-- | app/graphql/types/notes/noteable_interface.rb | 5 | ||||
-rw-r--r-- | app/graphql/types/notes/system_note_metadata_type.rb | 22 |
3 files changed, 83 insertions, 38 deletions
diff --git a/app/graphql/types/notes/note_type.rb b/app/graphql/types/notes/note_type.rb index 05629ea9223..5055facb21b 100644 --- a/app/graphql/types/notes/note_type.rb +++ b/app/graphql/types/notes/note_type.rb @@ -11,54 +11,72 @@ module Types implements(Types::ResolvableInterface) - field :id, ::Types::GlobalIDType[::Note], null: false, - description: 'ID of the note.' + field :id, ::Types::GlobalIDType[::Note], + null: false, + description: 'ID of the note.' field :project, Types::ProjectType, - null: true, - description: 'Project associated with the note.' + null: true, + description: 'Project associated with the note.' field :author, Types::UserType, - null: false, - description: 'User who wrote this note.' + null: false, + description: 'User who wrote this note.' field :system, GraphQL::Types::Boolean, - null: false, - description: 'Indicates whether this note was created by the system or by a user.' + null: false, + description: 'Indicates whether this note was created by the system or by a user.' field :system_note_icon_name, - GraphQL::Types::String, - null: true, - description: 'Name of the icon corresponding to a system note.' + GraphQL::Types::String, + null: true, + description: 'Name of the icon corresponding to a system note.' field :body, GraphQL::Types::String, - null: false, - method: :note, - description: 'Content of the note.' - - field :confidential, GraphQL::Types::Boolean, null: true, - description: 'Indicates if this note is confidential.', - method: :confidential?, - deprecated: { - reason: :renamed, - replacement: 'internal', - milestone: '15.5' - } - - field :internal, GraphQL::Types::Boolean, null: true, - description: 'Indicates if this note is internal.', - method: :confidential? - - field :created_at, Types::TimeType, null: false, - description: 'Timestamp of the note creation.' - field :discussion, Types::Notes::DiscussionType, null: true, - description: 'Discussion this note is a part of.' - field :position, Types::Notes::DiffPositionType, null: true, - description: 'Position of this note on a diff.' - field :updated_at, Types::TimeType, null: false, - description: "Timestamp of the note's last activity." + null: false, + method: :note, + description: 'Content of the note.' + + field :confidential, GraphQL::Types::Boolean, + null: true, + description: 'Indicates if this note is confidential.', + method: :confidential?, + deprecated: { + reason: :renamed, + replacement: 'internal', + milestone: '15.5' + } + + field :internal, GraphQL::Types::Boolean, + null: true, + description: 'Indicates if this note is internal.', + method: :confidential? + + field :created_at, Types::TimeType, + null: false, + description: 'Timestamp of the note creation.' + field :discussion, Types::Notes::DiscussionType, + null: true, + description: 'Discussion this note is a part of.' + field :position, Types::Notes::DiffPositionType, + null: true, + description: 'Position of this note on a diff.' + field :updated_at, Types::TimeType, + null: false, + description: "Timestamp of the note's last activity." field :url, GraphQL::Types::String, - null: true, - description: 'URL to view this Note in the Web UI.' + null: true, + description: 'URL to view this Note in the Web UI.' + + field :last_edited_at, Types::TimeType, + null: true, + description: 'Timestamp when note was last edited.' + field :last_edited_by, Types::UserType, + null: true, + description: 'User who last edited the note.' + + field :system_note_metadata, Types::Notes::SystemNoteMetadataType, + null: true, + description: 'Metadata for the given note if it is a system note.' markdown_field :body_html, null: true, method: :note diff --git a/app/graphql/types/notes/noteable_interface.rb b/app/graphql/types/notes/noteable_interface.rb index bd22f12d6f0..537084dff62 100644 --- a/app/graphql/types/notes/noteable_interface.rb +++ b/app/graphql/types/notes/noteable_interface.rb @@ -7,6 +7,7 @@ module Types field :notes, Types::Notes::NoteType.connection_type, null: false, description: "All notes on this noteable." field :discussions, Types::Notes::DiscussionType.connection_type, null: false, description: "All discussions on this noteable." + field :commenters, Types::UserType.connection_type, null: false, description: "All commenters on this noteable." def self.resolve_type(object, context) case object @@ -24,6 +25,10 @@ module Types raise "Unknown GraphQL type for #{object}" end end + + def commenters + object.commenters(user: current_user) + end end end end diff --git a/app/graphql/types/notes/system_note_metadata_type.rb b/app/graphql/types/notes/system_note_metadata_type.rb new file mode 100644 index 00000000000..b3dd7e037f9 --- /dev/null +++ b/app/graphql/types/notes/system_note_metadata_type.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +module Types + module Notes + class SystemNoteMetadataType < BaseObject + graphql_name 'SystemNoteMetadata' + + authorize :read_note + + field :id, ::Types::GlobalIDType[::SystemNoteMetadata], + null: false, + description: 'Global ID of the specific system note metadata.' + + field :action, GraphQL::Types::String, + null: true, + description: 'System note metadata action.' + field :description_version, ::Types::DescriptionVersionType, + null: true, + description: 'Version of the changed description.' + end + end +end |