Class: Resolvers::Snippets::BlobsResolver

Inherits:
BaseResolver
  • Object
show all
Includes:
Gitlab::Graphql::Authorize::AuthorizeResource
Defined in:
app/graphql/resolvers/snippets/blobs_resolver.rb

Constant Summary

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::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, field_options, 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!

Instance Method Details

#resolve(paths: []) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'app/graphql/resolvers/snippets/blobs_resolver.rb', line 19

def resolve(paths: [])
  return [snippet.blob] if snippet.empty_repo?

  paths = snippet.all_files if paths.empty?
  blobs = snippet.blobs(paths)

  # TODO: Some blobs, e.g. those with non-utf8 filenames, are returned as nil from the
  # repository. We need to provide a flag to notify the user of this until we come up with a
  # way to retrieve and display these blobs. We will be exploring a more holistic solution for
  # this general problem of making all blobs retrievable as part
  # of https://gitlab.com/gitlab-org/gitlab/-/issues/323082, at which point this attribute may
  # be removed.
  context[:unretrievable_blobs?] = blobs.size < paths.size

  blobs
end