summaryrefslogtreecommitdiff
path: root/app/graphql/types/user_merge_request_interaction_type.rb
blob: 06e318be5c6e8418ba28a12938e6e6bd4dfe55d7 (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
# frozen_string_literal: true

module Types
  class UserMergeRequestInteractionType < BaseObject
    graphql_name 'UserMergeRequestInteraction'
    description <<~MD
      Information about a merge request given a specific user.

      This object has two parts to its state: a `User` and a `MergeRequest`. All
      fields relate to interactions between the two entities.
    MD

    authorize :read_merge_request

    field :can_merge,
          type: ::GraphQL::Types::Boolean,
          null: false,
          calls_gitaly: true,
          method: :can_merge?,
          description: 'Whether this user can merge this merge request.'

    field :can_update,
          type: ::GraphQL::Types::Boolean,
          null: false,
          method: :can_update?,
          description: 'Whether this user can update this merge request.'

    field :review_state,
          ::Types::MergeRequestReviewStateEnum,
          null: true,
          description: 'State of the review by this user.'

    field :reviewed,
          type: ::GraphQL::Types::Boolean,
          null: false,
          method: :reviewed?,
          description: 'Whether this user has provided a review for this merge request.'

    field :approved,
          type: ::GraphQL::Types::Boolean,
          null: false,
          method: :approved?,
          description: 'Whether this user has approved this merge request.'
  end
end

::Types::UserMergeRequestInteractionType.prepend_mod_with('Types::UserMergeRequestInteractionType')