From 6af29c941af34330dd4f9ed9c513823d8067243b Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Mon, 16 Dec 2019 00:07:33 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- app/graphql/types/notes/diff_position_type.rb | 24 +++++++++++--------- app/graphql/types/notes/discussion_type.rb | 12 ++++++---- app/graphql/types/notes/note_type.rb | 32 +++++++++++++++++---------- 3 files changed, 41 insertions(+), 27 deletions(-) (limited to 'app/graphql/types/notes') diff --git a/app/graphql/types/notes/diff_position_type.rb b/app/graphql/types/notes/diff_position_type.rb index cab8c750dc0..654562da0a7 100644 --- a/app/graphql/types/notes/diff_position_type.rb +++ b/app/graphql/types/notes/diff_position_type.rb @@ -7,36 +7,38 @@ module Types class DiffPositionType < BaseObject graphql_name 'DiffPosition' - field :diff_refs, Types::DiffRefsType, null: false # rubocop:disable Graphql/Descriptions + field :diff_refs, Types::DiffRefsType, null: false, + description: 'Information about the branch, HEAD, and base at the time of commenting' field :file_path, GraphQL::STRING_TYPE, null: false, - description: "The path of the file that was changed" + description: 'Path of the file that was changed' field :old_path, GraphQL::STRING_TYPE, null: true, - description: "The path of the file on the start sha." + description: 'Path of the file on the start SHA' field :new_path, GraphQL::STRING_TYPE, null: true, - description: "The path of the file on the head sha." - field :position_type, Types::Notes::PositionTypeEnum, null: false # rubocop:disable Graphql/Descriptions + description: 'Path of the file on the HEAD SHA' + field :position_type, Types::Notes::PositionTypeEnum, null: false, + description: 'Type of file the position refers to' # Fields for text positions field :old_line, GraphQL::INT_TYPE, null: true, - description: "The line on start sha that was changed", + description: 'Line on start SHA that was changed', resolve: -> (position, _args, _ctx) { position.old_line if position.on_text? } field :new_line, GraphQL::INT_TYPE, null: true, - description: "The line on head sha that was changed", + description: 'Line on HEAD SHA that was changed', resolve: -> (position, _args, _ctx) { position.new_line if position.on_text? } # Fields for image positions field :x, GraphQL::INT_TYPE, null: true, - description: "The X postion on which the comment was made", + description: 'X position on which the comment was made', resolve: -> (position, _args, _ctx) { position.x if position.on_image? } field :y, GraphQL::INT_TYPE, null: true, - description: "The Y position on which the comment was made", + description: 'Y position on which the comment was made', resolve: -> (position, _args, _ctx) { position.y if position.on_image? } field :width, GraphQL::INT_TYPE, null: true, - description: "The total width of the image", + description: 'Total width of the image', resolve: -> (position, _args, _ctx) { position.width if position.on_image? } field :height, GraphQL::INT_TYPE, null: true, - description: "The total height of the image", + description: 'Total height of the image', resolve: -> (position, _args, _ctx) { position.height if position.on_image? } end # rubocop: enable Graphql/AuthorizeTypes diff --git a/app/graphql/types/notes/discussion_type.rb b/app/graphql/types/notes/discussion_type.rb index ab87f8280ac..74a233e9d26 100644 --- a/app/graphql/types/notes/discussion_type.rb +++ b/app/graphql/types/notes/discussion_type.rb @@ -7,10 +7,14 @@ module Types authorize :read_note - field :id, GraphQL::ID_TYPE, null: false # rubocop:disable Graphql/Descriptions - field :reply_id, GraphQL::ID_TYPE, null: false, description: 'The ID used to reply to this discussion' - field :created_at, Types::TimeType, null: false # rubocop:disable Graphql/Descriptions - field :notes, Types::Notes::NoteType.connection_type, null: false, description: "All notes in the discussion" + field :id, GraphQL::ID_TYPE, null: false, + description: "ID of this discussion" + field :reply_id, GraphQL::ID_TYPE, null: false, + description: 'ID used to reply to this discussion' + field :created_at, Types::TimeType, null: false, + description: "Timestamp of the discussion's creation" + field :notes, Types::Notes::NoteType.connection_type, null: false, + description: 'All notes in the discussion' # The gem we use to generate Global IDs is hard-coded to work with # `id` properties. To generate a GID for the `reply_id` property, diff --git a/app/graphql/types/notes/note_type.rb b/app/graphql/types/notes/note_type.rb index 4edf6ed90f7..b60fc96bd03 100644 --- a/app/graphql/types/notes/note_type.rb +++ b/app/graphql/types/notes/note_type.rb @@ -9,40 +9,48 @@ module Types expose_permissions Types::PermissionTypes::Note - field :id, GraphQL::ID_TYPE, null: false # rubocop:disable Graphql/Descriptions + field :id, GraphQL::ID_TYPE, null: false, + description: 'ID of the note' field :project, Types::ProjectType, null: true, - description: "The project this note is associated to", + description: 'Project associated with the note', resolve: -> (note, args, context) { Gitlab::Graphql::Loaders::BatchModelLoader.new(Project, note.project_id).find } field :author, Types::UserType, null: false, - description: "The user who wrote this note", + description: 'User who wrote this note', resolve: -> (note, args, context) { Gitlab::Graphql::Loaders::BatchModelLoader.new(User, note.author_id).find } field :resolved_by, Types::UserType, null: true, - description: "The user that resolved the discussion", + description: 'User that resolved the discussion', resolve: -> (note, _args, _context) { Gitlab::Graphql::Loaders::BatchModelLoader.new(User, note.resolved_by_id).find } field :system, GraphQL::BOOLEAN_TYPE, null: false, - description: "Whether or not this note was created by the system or by a user" + description: 'Indicates whether this note was created by the system or by a user' field :body, GraphQL::STRING_TYPE, null: false, method: :note, - description: "The content note itself" + description: 'Content of the note' markdown_field :body_html, null: true, method: :note - field :created_at, Types::TimeType, null: false # rubocop:disable Graphql/Descriptions - field :updated_at, Types::TimeType, null: false # rubocop:disable Graphql/Descriptions - field :discussion, Types::Notes::DiscussionType, null: true, description: "The discussion this note is a part of" - field :resolvable, GraphQL::BOOLEAN_TYPE, null: false, method: :resolvable? # rubocop:disable Graphql/Descriptions - field :resolved_at, Types::TimeType, null: true, description: "The time the discussion was resolved" - field :position, Types::Notes::DiffPositionType, null: true, description: "The position of this note on a diff" + field :created_at, Types::TimeType, null: false, + description: 'Timestamp of the note creation' + field :updated_at, Types::TimeType, null: false, + description: "Timestamp of the note's last activity" + field :discussion, Types::Notes::DiscussionType, null: true, + description: 'The discussion this note is a part of' + field :resolvable, GraphQL::BOOLEAN_TYPE, null: false, + description: 'Indicates if this note can be resolved. That is, if it is a resolvable discussion or simply a standalone note', + method: :resolvable? + field :resolved_at, Types::TimeType, null: true, + description: "Timestamp of the note's resolution" + field :position, Types::Notes::DiffPositionType, null: true, + description: 'The position of this note on a diff' end end end -- cgit v1.2.1