debian-mirror-gitlab/app/graphql/types/tree/tree_type.rb

35 lines
1.4 KiB
Ruby
Raw Normal View History

2019-09-04 21:01:54 +05:30
# frozen_string_literal: true
module Types
module Tree
2019-09-30 21:07:59 +05:30
# rubocop: disable Graphql/AuthorizeTypes
# This is presented through `Repository` that has its own authorization
2019-09-04 21:01:54 +05:30
class TreeType < BaseObject
graphql_name 'Tree'
2019-09-30 21:07:59 +05:30
# Complexity 10 as it triggers a Gitaly call on each render
2019-12-21 20:55:43 +05:30
field :last_commit, Types::CommitType,
null: true, complexity: 10, calls_gitaly: true, resolver: Resolvers::LastCommitResolver,
description: 'Last commit for the tree'
2019-09-30 21:07:59 +05:30
2020-03-13 15:44:24 +05:30
field :trees, Types::Tree::TreeEntryType.connection_type, null: false,
description: 'Trees of the tree',
resolve: -> (obj, args, ctx) do
Gitlab::Graphql::Representation::TreeEntry.decorate(obj.trees, obj.repository)
end
2019-09-04 21:01:54 +05:30
2020-03-13 15:44:24 +05:30
field :submodules, Types::Tree::SubmoduleType.connection_type, null: false,
description: 'Sub-modules of the tree',
calls_gitaly: true, resolve: -> (obj, args, ctx) do
Gitlab::Graphql::Representation::SubmoduleTreeEntry.decorate(obj.submodules, obj)
end
2019-09-04 21:01:54 +05:30
2020-03-13 15:44:24 +05:30
field :blobs, Types::Tree::BlobType.connection_type, null: false,
description: 'Blobs of the tree',
calls_gitaly: true, resolve: -> (obj, args, ctx) do
Gitlab::Graphql::Representation::TreeEntry.decorate(obj.blobs, obj.repository)
end
2019-09-30 21:07:59 +05:30
# rubocop: enable Graphql/AuthorizeTypes
2019-09-04 21:01:54 +05:30
end
end
end