2019-09-04 21:01:54 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Types
|
|
|
|
module Notes
|
|
|
|
class NoteType < BaseObject
|
|
|
|
graphql_name 'Note'
|
|
|
|
|
|
|
|
authorize :read_note
|
|
|
|
|
|
|
|
expose_permissions Types::PermissionTypes::Note
|
|
|
|
|
2019-12-04 20:38:33 +05:30
|
|
|
field :id, GraphQL::ID_TYPE, null: false # rubocop:disable Graphql/Descriptions
|
2019-09-04 21:01:54 +05:30
|
|
|
|
|
|
|
field :project, Types::ProjectType,
|
|
|
|
null: true,
|
|
|
|
description: "The project this note is associated to",
|
|
|
|
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",
|
|
|
|
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",
|
|
|
|
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"
|
|
|
|
|
|
|
|
field :body, GraphQL::STRING_TYPE,
|
|
|
|
null: false,
|
|
|
|
method: :note,
|
|
|
|
description: "The content note itself"
|
|
|
|
|
2019-09-30 21:07:59 +05:30
|
|
|
markdown_field :body_html, null: true, method: :note
|
|
|
|
|
2019-12-04 20:38:33 +05:30
|
|
|
field :created_at, Types::TimeType, null: false # rubocop:disable Graphql/Descriptions
|
|
|
|
field :updated_at, Types::TimeType, null: false # rubocop:disable Graphql/Descriptions
|
2019-09-04 21:01:54 +05:30
|
|
|
field :discussion, Types::Notes::DiscussionType, null: true, description: "The discussion this note is a part of"
|
2019-12-04 20:38:33 +05:30
|
|
|
field :resolvable, GraphQL::BOOLEAN_TYPE, null: false, method: :resolvable? # rubocop:disable Graphql/Descriptions
|
2019-09-04 21:01:54 +05:30
|
|
|
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"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|