2019-05-22 11:43:35 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
module Types
|
|
|
|
module Tree
|
2019-06-18 16:31:06 +00:00
|
|
|
# rubocop: disable Graphql/AuthorizeTypes
|
|
|
|
# This is presented through `Repository` that has its own authorization
|
2019-05-22 11:43:35 +00:00
|
|
|
class TreeType < BaseObject
|
|
|
|
graphql_name 'Tree'
|
|
|
|
|
2019-06-28 07:30:29 +00:00
|
|
|
# Complexity 10 as it triggers a Gitaly call on each render
|
2019-10-03 18:06:11 +00:00
|
|
|
field :last_commit, Types::CommitType,
|
2020-12-01 12:09:17 +00:00
|
|
|
null: true, complexity: 10, calls_gitaly: true, resolver: Resolvers::LastCommitResolver,
|
2021-02-05 15:09:28 +00:00
|
|
|
description: 'Last commit for the tree.'
|
2019-06-28 07:30:29 +00:00
|
|
|
|
2020-01-06 09:07:42 +00:00
|
|
|
field :trees, Types::Tree::TreeEntryType.connection_type, null: false,
|
2021-02-05 15:09:28 +00:00
|
|
|
description: 'Trees of the tree.'
|
2019-06-04 13:38:18 +00:00
|
|
|
|
2020-01-06 09:07:42 +00:00
|
|
|
field :submodules, Types::Tree::SubmoduleType.connection_type, null: false,
|
2021-02-05 15:09:28 +00:00
|
|
|
description: 'Sub-modules of the tree.',
|
2020-12-01 12:09:17 +00:00
|
|
|
calls_gitaly: true
|
2019-06-04 13:38:18 +00:00
|
|
|
|
2020-01-06 09:07:42 +00:00
|
|
|
field :blobs, Types::Tree::BlobType.connection_type, null: false,
|
2021-02-05 15:09:28 +00:00
|
|
|
description: 'Blobs of the tree.',
|
2020-12-01 12:09:17 +00:00
|
|
|
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
|
2019-05-22 11:43:35 +00:00
|
|
|
end
|
2020-12-01 12:09:17 +00:00
|
|
|
# rubocop: enable Graphql/AuthorizeTypes
|
2019-05-22 11:43:35 +00:00
|
|
|
end
|
|
|
|
end
|