Class: Resolvers::WorkItemsResolver

Inherits:
BaseResolver
  • Object
show all
Includes:
SearchArguments, WorkItems::LookAheadPreloads, WorkItems::NonStableCursorSortOptions, WorkItems::SharedFilterArguments
Defined in:
app/graphql/resolvers/work_items_resolver.rb

Constant Summary

Constants included from WorkItems::NonStableCursorSortOptions

WorkItems::NonStableCursorSortOptions::NON_STABLE_CURSOR_SORTS

Constants included from WorkItems::SharedFilterArguments

WorkItems::SharedFilterArguments::MAX_FIELD_LIMIT

Constants included from Gitlab::Graphql::Authorize::AuthorizeResource

Gitlab::Graphql::Authorize::AuthorizeResource::ConfigurationError, Gitlab::Graphql::Authorize::AuthorizeResource::RESOURCE_ACCESS_ERROR

Instance Method Summary collapse

Methods included from Gitlab::Utils::Override

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

Methods included from SearchArguments

#ready?

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!, calls_gitaly?, complexity, complexity_multiplier, #current_user, last, #object, #offset_pagination, requires_argument!, requires_argument?, resolver_complexity, #select_result, single, #single?, single_definition_blocks, singular_type, when_single

Instance Method Details

#resolve_with_lookahead(**args) ⇒ Object



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
# File 'app/graphql/resolvers/work_items_resolver.rb', line 22

def resolve_with_lookahead(**args)
  return WorkItem.none if resource_parent.nil?

  # Adding skip_type_authorization in the resolver while it is conditionally enabled.
  # It can be moved to the field definition once the feature flag is removed
  # Issue: https://gitlab.com/gitlab-org/gitlab/-/issues/548096
  context.scoped_set!(:skip_type_authorization, [:read_work_item]) if skip_field_authorization?

  finder = choose_finder(args)

  using_elasticsearch = using_elasticsearch_finder?(finder)

  items = Gitlab::Graphql::Loaders::IssuableLoader
    .new(resource_parent, finder)
    .batching_find_all { |q| apply_lookahead(q) }

  if non_stable_cursor_sort?(args[:sort]) && !using_elasticsearch
    # Certain complex sorts are not supported by the stable cursor pagination yet.
    # In these cases, we use offset pagination, so we return the correct connection.
    # However, we do allow those sorts when it's an Advanced Search finder searching in ES
    offset_pagination(items)
  else
    items
  end
end