Class: Resolvers::PackagePipelinesResolver
- Inherits:
-
BaseResolver
- Object
- GraphQL::Schema::Resolver
- BaseResolver
- Resolvers::PackagePipelinesResolver
- Defined in:
- app/graphql/resolvers/package_pipelines_resolver.rb
Constant Summary collapse
- MAX_PAGE_SIZE =
this resolver can be called for 100 packages max and we want to limit the number of build infos returned for each package when using the new finder.
20
Constants included from Gitlab::Graphql::Authorize::AuthorizeResource
Gitlab::Graphql::Authorize::AuthorizeResource::ConfigurationError, Gitlab::Graphql::Authorize::AuthorizeResource::RESOURCE_ACCESS_ERROR
Class Method Summary collapse
-
.field_options ⇒ Object
we manage the pagination manually, so opt out of the connection field extension.
Instance Method Summary collapse
-
#resolve(lookahead:, first: nil, last: nil, after: nil, before: nil) ⇒ Object
This returns a promise for a connection of promises for pipelines: Lazy[Connection[Lazy]] structure.
Methods included from Gitlab::Graphql::Authorize::AuthorizeResource
#authorize!, #authorized_find!, #authorized_resource?, #find_object, #raise_resource_not_available_error!
Methods inherited from BaseResolver
as_single, authorization, authorized?, before_connection_authorization, before_connection_authorization_block, calculate_ext_conn_complexity, calls_gitaly!, complexity, complexity_multiplier, #current_user, last, #object, #offset_pagination, requires_argument!, resolver_complexity, #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!
Class Method Details
.field_options ⇒ Object
we manage the pagination manually, so opt out of the connection field extension
45 46 47 48 49 50 |
# File 'app/graphql/resolvers/package_pipelines_resolver.rb', line 45 def self. super.merge( connection: false, extras: [:lookahead] ) end |
Instance Method Details
#resolve(lookahead:, first: nil, last: nil, after: nil, before: nil) ⇒ Object
This returns a promise for a connection of promises for pipelines: Lazy[Connection[Lazy]] structure
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'app/graphql/resolvers/package_pipelines_resolver.rb', line 21 def resolve(lookahead:, first: nil, last: nil, after: nil, before: nil) default_value = default_value_for(first: first, last: last, after: after, before: before) BatchLoader::GraphQL.for(package.id) .batch(default_value: default_value) do |package_ids, loader| build_infos = ::Packages::BuildInfosFinder.new( package_ids, first: first, last: last, after: decode_cursor(after), before: decode_cursor(before), max_page_size: MAX_PAGE_SIZE, support_next_page: lookahead.selects?(:page_info) ).execute build_infos.each do |build_info| loader.call(build_info.package_id) do |connection| connection.items << lazy_load_pipeline(build_info.pipeline_id) connection end end end end |