Welcome to mirror list, hosted at ThFree Co, Russian Federation.

tree_type.rb « tree « types « graphql « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 011cff0c89c97d3bbaf11e194f093a8030053ceb (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
29
30
31
32
33
34
35
36
37
38
39
# frozen_string_literal: true
module Types
  module Tree
    # rubocop: disable Graphql/AuthorizeTypes
    # This is presented through `Repository` that has its own authorization
    class TreeType < BaseObject
      graphql_name 'Tree'

      # Complexity 10 as it triggers a Gitaly call on each render
      field :last_commit, Types::CommitType,
            null: true, complexity: 10, calls_gitaly: true, resolver: Resolvers::LastCommitResolver,
            description: 'Last commit for the tree.'

      field :trees, Types::Tree::TreeEntryType.connection_type, null: false,
            description: 'Trees of the tree.'

      field :submodules, Types::Tree::SubmoduleType.connection_type, null: false,
            description: 'Sub-modules of the tree.',
            calls_gitaly: true

      field :blobs, Types::Tree::BlobType.connection_type, null: false,
            description: 'Blobs of the tree.',
            calls_gitaly: true

      def trees
        Gitlab::Graphql::Representation::TreeEntry.decorate(object.trees, object.repository)
      end

      def submodules
        Gitlab::Graphql::Representation::SubmoduleTreeEntry.decorate(object.submodules, object)
      end

      def blobs
        Gitlab::Graphql::Representation::TreeEntry.decorate(object.blobs, object.repository)
      end
    end
    # rubocop: enable Graphql/AuthorizeTypes
  end
end