Class: Types::CommitReferencesType

Inherits:
BaseObject
  • Object
show all
Defined in:
app/graphql/types/commit_references_type.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseObject

accepts, assignable?, authorization, authorize, authorized?, #current_user, #id

Methods included from Gitlab::Graphql::Present

#present, #unpresented

Class Method Details

.field_for_containing_refs(field_name, field_description) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'app/graphql/types/commit_references_type.rb', line 22

def self.field_for_containing_refs(field_name, field_description)
  field field_name, ::Types::Projects::CommitParentNamesType,
    null: true,
    calls_gitaly: true,
    description: field_description do
    argument :exclude_tipped, GraphQL::Types::Boolean,
      required: true,
      default_value: false,
      description: 'Exclude tipping refs. WARNING: This argument can be confusing, if there is a limit.
      for example set the limit to 5 and in the 5 out a total of 25 refs there is 2 tipped refs,
      then the method will only 3 refs, even though there is more.'
    # rubocop: disable GraphQL/ArgumentUniqueness
    argument :limit, GraphQL::Types::Int,
      required: true,
      default_value: 100,
      description: 'Number of ref names to return.',
      validates: { numericality: { within: 1..1000 } }
    # rubocop: enable GraphQL/ArgumentUniqueness
  end
end

.field_for_tipping_refs(field_name, field_description) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/graphql/types/commit_references_type.rb', line 9

def self.field_for_tipping_refs(field_name, field_description)
  field field_name, ::Types::Projects::CommitParentNamesType,
    null: true,
    calls_gitaly: true,
    description: field_description do
      argument :limit, GraphQL::Types::Int,
        required: true,
        default_value: 100,
        description: 'Number of ref names to return.',
        validates: { numericality: { within: 1..1000 } }
    end
end

Instance Method Details

#containing_branches(limit:, exclude_tipped:) ⇒ Object



63
64
65
# File 'app/graphql/types/commit_references_type.rb', line 63

def containing_branches(limit:, exclude_tipped:)
  { names: object.branches_containing(limit: limit, exclude_tipped: exclude_tipped) }
end

#containing_tags(limit:, exclude_tipped:) ⇒ Object



59
60
61
# File 'app/graphql/types/commit_references_type.rb', line 59

def containing_tags(limit:, exclude_tipped:)
  { names: object.tags_containing(limit: limit, exclude_tipped: exclude_tipped) }
end

#tipping_branches(limit:) ⇒ Object



55
56
57
# File 'app/graphql/types/commit_references_type.rb', line 55

def tipping_branches(limit:)
  { names: object.tipping_branches(limit: limit) }
end

#tipping_tags(limit:) ⇒ Object



51
52
53
# File 'app/graphql/types/commit_references_type.rb', line 51

def tipping_tags(limit:)
  { names: object.tipping_tags(limit: limit) }
end