Class: Resolvers::ProjectPipelineResolver

Inherits:
BaseResolver
  • Object
show all
Includes:
LooksAhead
Defined in:
app/graphql/resolvers/project_pipeline_resolver.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from LooksAhead

#apply_lookahead

Methods inherited from BaseResolver

as_single, authorization, authorized?, before_connection_authorization, before_connection_authorization_block, calls_gitaly!, complexity, complexity_multiplier, #current_user, field_options, last, #object, #offset_pagination, requires_argument!, #select_result, single, #single?, single_definition_blocks, singular_type, when_single

Methods included from Gitlab::Utils::Override

#extended, extensions, #included, #method_added, #override, #prepended, #queue_verification, verify!

Methods included from Gitlab::Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

Class Method Details

.resolver_complexity(args, child_complexity:) ⇒ Object


51
52
53
54
# File 'app/graphql/resolvers/project_pipeline_resolver.rb', line 51

def self.resolver_complexity(args, child_complexity:)
  complexity = super
  complexity - 10
end

Instance Method Details

#ready?(iid: nil, sha: nil, **args) ⇒ Boolean

Returns:

  • (Boolean)

19
20
21
22
23
24
25
# File 'app/graphql/resolvers/project_pipeline_resolver.rb', line 19

def ready?(iid: nil, sha: nil, **args)
  unless iid.present? ^ sha.present?
    raise Gitlab::Graphql::Errors::ArgumentError, 'Provide one of an IID or SHA'
  end

  super
end

#resolve(iid: nil, sha: nil, **args) ⇒ Object


27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'app/graphql/resolvers/project_pipeline_resolver.rb', line 27

def resolve(iid: nil, sha: nil, **args)
  self.lookahead = args.delete(:lookahead)

  if iid
    BatchLoader::GraphQL.for(iid).batch(key: project) do |iids, loader|
      finder = ::Ci::PipelinesFinder.new(project, current_user, iids: iids)

      apply_lookahead(finder.execute).each { |pipeline| loader.call(pipeline.iid.to_s, pipeline) }
    end
  else
    BatchLoader::GraphQL.for(sha).batch(key: project) do |shas, loader|
      finder = ::Ci::PipelinesFinder.new(project, current_user, sha: shas)

      apply_lookahead(finder.execute).each { |pipeline| loader.call(pipeline.sha.to_s, pipeline) }
    end
  end
end

#unconditional_includesObject


45
46
47
48
49
# File 'app/graphql/resolvers/project_pipeline_resolver.rb', line 45

def unconditional_includes
  [
    { statuses: [:needs] }
  ]
end