summaryrefslogtreecommitdiff
path: root/app/graphql/types/projects/branch_rule_type.rb
blob: 08b1203d4a30ee82a584dd197e79edfb955e7a50 (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
49
50
51
52
53
54
# frozen_string_literal: true

module Types
  module Projects
    class BranchRuleType < BaseObject
      graphql_name 'BranchRule'
      description 'List of branch rules for a project, grouped by branch name.'
      authorize :read_protected_branch

      alias_method :branch_rule, :object

      field :name,
            type: GraphQL::Types::String,
            null: false,
            description: 'Branch name, with wildcards, for the branch rules.'

      field :is_default,
            type: GraphQL::Types::Boolean,
            null: false,
            method: :default_branch?,
            calls_gitaly: true,
            description: "Check if this branch rule protects the project's default branch."

      field :is_protected,
            type: GraphQL::Types::Boolean,
            null: false,
            method: :protected?,
            description: "Check if this branch rule protects access for the branch."

      field :matching_branches_count,
            type: GraphQL::Types::Int,
            null: false,
            calls_gitaly: true,
            description: 'Number of existing branches that match this branch rule.'

      field :branch_protection,
            type: Types::BranchRules::BranchProtectionType,
            null: true,
            description: 'Branch protections configured for this branch rule.'

      field :created_at,
            Types::TimeType,
            null: false,
            description: 'Timestamp of when the branch rule was created.'

      field :updated_at,
            Types::TimeType,
            null: false,
            description: 'Timestamp of when the branch rule was last updated.'
    end
  end
end

Types::Projects::BranchRuleType.prepend_mod