Module: ResolvesPipelines

Extended by:
ActiveSupport::Concern
Included in:
Resolvers::Ci::ProjectPipelinesResolver, Resolvers::CommitPipelinesResolver, Resolvers::MergeRequestPipelinesResolver
Defined in:
app/graphql/resolvers/concerns/resolves_pipelines.rb

Constant Summary collapse

MAX_PIPELINE_IDS =
20
REF_TYPE_SCOPE_MAP =
{
  'heads' => 'branches',
  'tags' => 'tags'
}.freeze

Instance Method Summary collapse

Instance Method Details

#resolve_pipelines(project, params = {}) ⇒ Object



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'app/graphql/resolvers/concerns/resolves_pipelines.rb', line 66

def resolve_pipelines(project, params = {})
  if params[:ids].present?
    if params[:ids].length > MAX_PIPELINE_IDS
      raise GraphQL::ExecutionError, "Cannot query more than #{MAX_PIPELINE_IDS} pipelines by ID at once."
    end

    params[:ids] = parse_pipeline_ids(params[:ids])
  end

  extract_scope_from_params!(params)

  pipelines = Ci::PipelinesFinder.new(project, context[:current_user], params).execute

  if %w[branches tags].include?(params[:scope])
    # `branches` and `tags` scopes are ordered in a complex way that is not supported by the keyset pagination.
    # We offset pagination here so we return the correct connection.
    offset_pagination(pipelines)
  else
    pipelines
  end
end