diff options
Diffstat (limited to 'app/graphql/types/tree')
-rw-r--r-- | app/graphql/types/tree/blob_type.rb | 11 | ||||
-rw-r--r-- | app/graphql/types/tree/tree_type.rb | 31 |
2 files changed, 24 insertions, 18 deletions
diff --git a/app/graphql/types/tree/blob_type.rb b/app/graphql/types/tree/blob_type.rb index cc6bf7b4f00..a7b90d2533b 100644 --- a/app/graphql/types/tree/blob_type.rb +++ b/app/graphql/types/tree/blob_type.rb @@ -15,13 +15,14 @@ module Types field :web_path, GraphQL::STRING_TYPE, null: true, description: 'Web path of the blob' field :lfs_oid, GraphQL::STRING_TYPE, null: true, - description: 'LFS ID of the blob', - resolve: -> (blob, args, ctx) do - Gitlab::Graphql::Loaders::BatchLfsOidLoader.new(blob.repository, blob.id).find - end + description: 'LFS ID of the blob' field :mode, GraphQL::STRING_TYPE, null: true, description: 'Blob mode in numeric format' - # rubocop: enable Graphql/AuthorizeTypes + + def lfs_oid + Gitlab::Graphql::Loaders::BatchLfsOidLoader.new(object.repository, object.id).find + end end + # rubocop: enable Graphql/AuthorizeTypes end end diff --git a/app/graphql/types/tree/tree_type.rb b/app/graphql/types/tree/tree_type.rb index b9fb6b28e71..fecd6c0f309 100644 --- a/app/graphql/types/tree/tree_type.rb +++ b/app/graphql/types/tree/tree_type.rb @@ -8,27 +8,32 @@ module Types # 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' + 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', - resolve: -> (obj, args, ctx) do - Gitlab::Graphql::Representation::TreeEntry.decorate(obj.trees, obj.repository) - end + description: 'Trees of the tree' 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 + calls_gitaly: true 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 - # rubocop: enable Graphql/AuthorizeTypes + 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 |