summaryrefslogtreecommitdiff
path: root/app/graphql/types/tree/blob_type.rb
blob: 3db64d812c5aac5a8db4820c8bc2b36706c186bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# frozen_string_literal: true
module Types
  module Tree
    # rubocop: disable Graphql/AuthorizeTypes
    # This is presented through `Repository` that has its own authorization
    class BlobType < BaseObject
      graphql_name 'Blob'

      implements Types::Tree::EntryType
      present_using BlobPresenter

      field :lfs_oid, GraphQL::Types::String, null: true,
                                              calls_gitaly: true,
                                              description: 'LFS ID of the blob.'
      field :mode, GraphQL::Types::String, null: true,
                                           description: 'Blob mode in numeric format.'
      field :web_path, GraphQL::Types::String, null: true,
                                               description: 'Web path of the blob.'
      field :web_url, GraphQL::Types::String, null: true,
                                              description: 'Web URL of the blob.'

      def lfs_oid
        Gitlab::Graphql::Loaders::BatchLfsOidLoader.new(object.repository, object.id).find
      end
    end
    # rubocop: enable Graphql/AuthorizeTypes
  end
end