Welcome to mirror list, hosted at ThFree Co, Russian Federation.

note_type.rb « notes « types « graphql « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: fe54a45c7dccfb4498b2e00c400d032dbd2f9cfe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# frozen_string_literal: true

module Types
  module Notes
    class NoteType < BaseObject
      graphql_name 'Note'

      authorize :read_note

      expose_permissions Types::PermissionTypes::Note

      field :id, GraphQL::ID_TYPE, null: false

      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"

      markdown_field :body_html, null: true, method: :note

      field :created_at, Types::TimeType, null: false
      field :updated_at, Types::TimeType, null: false
      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?
      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