diff options
author | Alessio Caiazza <acaiazza@gitlab.com> | 2019-05-13 00:10:46 +0300 |
---|---|---|
committer | Alessio Caiazza <acaiazza@gitlab.com> | 2019-06-03 13:01:32 +0300 |
commit | 83a8b779615c968af5afe15a1cbc6903d639f265 (patch) | |
tree | fb98c67d6e184ff2b283ad26b82fc9d3316191a4 /app/graphql/types | |
parent | ac03f30cd938cd2c75d05cbc7adbde3f42666ab1 (diff) |
Add Namespace and ProjectStatistics to GraphQL API
We can query namespaces, and nested projects.
Projects now exposes statistics
Diffstat (limited to 'app/graphql/types')
-rw-r--r-- | app/graphql/types/namespace_type.rb | 5 | ||||
-rw-r--r-- | app/graphql/types/project_statistics_type.rb | 15 | ||||
-rw-r--r-- | app/graphql/types/project_type.rb | 4 | ||||
-rw-r--r-- | app/graphql/types/query_type.rb | 5 |
4 files changed, 29 insertions, 0 deletions
diff --git a/app/graphql/types/namespace_type.rb b/app/graphql/types/namespace_type.rb index 36d8ee8c878..f6d91320e50 100644 --- a/app/graphql/types/namespace_type.rb +++ b/app/graphql/types/namespace_type.rb @@ -15,5 +15,10 @@ module Types field :visibility, GraphQL::STRING_TYPE, null: true field :lfs_enabled, GraphQL::BOOLEAN_TYPE, null: true, method: :lfs_enabled? field :request_access_enabled, GraphQL::BOOLEAN_TYPE, null: true + + field :projects, + Types::ProjectType.connection_type, + null: false, + resolver: ::Resolvers::NamespaceProjectsResolver end end diff --git a/app/graphql/types/project_statistics_type.rb b/app/graphql/types/project_statistics_type.rb new file mode 100644 index 00000000000..35ae23c21fc --- /dev/null +++ b/app/graphql/types/project_statistics_type.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +module Types + class ProjectStatisticsType < BaseObject + graphql_name 'ProjectStatistics' + + field :commit_count, GraphQL::INT_TYPE, null: false + + field :storage_size, GraphQL::INT_TYPE, null: false + field :repository_size, GraphQL::INT_TYPE, null: false + field :lfs_objects_size, GraphQL::INT_TYPE, null: false + field :build_artifacts_size, GraphQL::INT_TYPE, null: false + field :packages_size, GraphQL::INT_TYPE, null: false + end +end diff --git a/app/graphql/types/project_type.rb b/app/graphql/types/project_type.rb index 06a1aab09f6..2236ffa394d 100644 --- a/app/graphql/types/project_type.rb +++ b/app/graphql/types/project_type.rb @@ -69,6 +69,10 @@ module Types field :namespace, Types::NamespaceType, null: false field :group, Types::GroupType, null: true + field :statistics, Types::ProjectStatisticsType, + null: false, + resolve: -> (obj, _args, _ctx) { Gitlab::Graphql::Loaders::BatchProjectStatisticsLoader.new(obj.id).find } + field :repository, Types::RepositoryType, null: false field :merge_requests, diff --git a/app/graphql/types/query_type.rb b/app/graphql/types/query_type.rb index 40d7de1a49a..536bdb077ad 100644 --- a/app/graphql/types/query_type.rb +++ b/app/graphql/types/query_type.rb @@ -14,6 +14,11 @@ module Types resolver: Resolvers::GroupResolver, description: "Find a group" + field :namespace, Types::NamespaceType, + null: true, + resolver: Resolvers::NamespaceResolver, + description: "Find a namespace" + field :metadata, Types::MetadataType, null: true, resolver: Resolvers::MetadataResolver, |