Commit e38dc069 authored by Nicolò Maria Mezzopera's avatar Nicolò Maria Mezzopera

Merge branch '276432-refactor-container-registry-frontend-to-graphql-2' into 'master'

Add containerRepositoriesCount to project and group queries

See merge request gitlab-org/gitlab!48685
parents 5afdf7f6 e474d17d
......@@ -88,10 +88,13 @@ module Types
field :container_repositories,
Types::ContainerRepositoryType.connection_type,
null: true,
description: 'Container repositories of the project',
description: 'Container repositories of the group',
resolver: Resolvers::ContainerRepositoriesResolver,
authorize: :read_container_image
field :container_repositories_count, GraphQL::INT_TYPE, null: false,
description: 'Number of container repositories in the group'
def label(title:)
BatchLoader::GraphQL.for(title).batch(key: group) do |titles, loader, args|
LabelsFinder
......@@ -124,6 +127,10 @@ module Types
Gitlab::Graphql::Loaders::BatchModelLoader.new(Group, object.parent_id).find
end
def container_repositories_count
group.container_repositories.size
end
private
def group
......
......@@ -286,6 +286,9 @@ module Types
description: 'Container repositories of the project',
resolver: Resolvers::ContainerRepositoriesResolver
field :container_repositories_count, GraphQL::INT_TYPE, null: false,
description: 'Number of container repositories in the project'
field :label,
Types::LabelType,
null: true,
......@@ -341,6 +344,10 @@ module Types
Gitlab::Graphql::Loaders::BatchProjectStatisticsLoader.new(object.id).find
end
def container_repositories_count
project.container_repositories.size
end
private
def project
......
---
title: Add containerRepositoriesCount to project and group queries
merge_request: 48685
author:
type: changed
......@@ -8819,7 +8819,7 @@ type Group {
): CodeCoverageActivityConnection
"""
Container repositories of the project
Container repositories of the group
"""
containerRepositories(
"""
......@@ -8848,6 +8848,11 @@ type Group {
name: String
): ContainerRepositoryConnection
"""
Number of container repositories in the group
"""
containerRepositoriesCount: Int!
"""
Includes at least one project where the repository size exceeds the limit
"""
......@@ -15622,6 +15627,11 @@ type Project {
name: String
): ContainerRepositoryConnection
"""
Number of container repositories in the project
"""
containerRepositoriesCount: Int!
"""
Timestamp of the project creation
"""
......
......@@ -24514,7 +24514,7 @@
},
{
"name": "containerRepositories",
"description": "Container repositories of the project",
"description": "Container repositories of the group",
"args": [
{
"name": "name",
......@@ -24575,6 +24575,24 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "containerRepositoriesCount",
"description": "Number of container repositories in the group",
"args": [
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "Int",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "containsLockedProjects",
"description": "Includes at least one project where the repository size exceeds the limit",
......@@ -46301,6 +46319,24 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "containerRepositoriesCount",
"description": "Number of container repositories in the project",
"args": [
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "Int",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "createdAt",
"description": "Timestamp of the project creation",
......@@ -1459,7 +1459,8 @@ Autogenerated return type of EpicTreeReorder.
| `board` | Board | A single board of the group |
| `boards` | BoardConnection | Boards of the group |
| `codeCoverageActivities` | CodeCoverageActivityConnection | Represents the code coverage activity for this group |
| `containerRepositories` | ContainerRepositoryConnection | Container repositories of the project |
| `containerRepositories` | ContainerRepositoryConnection | Container repositories of the group |
| `containerRepositoriesCount` | Int! | Number of container repositories in the group |
| `containsLockedProjects` | Boolean! | Includes at least one project where the repository size exceeds the limit |
| `customEmoji` | CustomEmojiConnection | Custom emoji within this namespace. Available only when feature flag `custom_emoji` is enabled |
| `description` | String | Description of the namespace |
......@@ -2393,6 +2394,7 @@ Autogenerated return type of PipelineRetry.
| `containerExpirationPolicy` | ContainerExpirationPolicy | The container expiration policy of the project |
| `containerRegistryEnabled` | Boolean | Indicates if the project stores Docker container images in a container registry |
| `containerRepositories` | ContainerRepositoryConnection | Container repositories of the project |
| `containerRepositoriesCount` | Int! | Number of container repositories in the project |
| `createdAt` | Time | Timestamp of the project creation |
| `dastScannerProfiles` | DastScannerProfileConnection | The DAST scanner profiles associated with the project |
| `dastSiteProfile` | DastSiteProfile | DAST Site Profile associated with the project |
......
......@@ -17,7 +17,7 @@ RSpec.describe GitlabSchema.types['Group'] do
subgroup_creation_level require_two_factor_authentication
two_factor_grace_period auto_devops_enabled emails_disabled
mentions_disabled parent boards milestones group_members
merge_requests
merge_requests container_repositories container_repositories_count
]
expect(described_class).to include_graphql_fields(*expected_fields)
......
......@@ -30,7 +30,7 @@ RSpec.describe GitlabSchema.types['Project'] do
alert_management_alerts alert_management_alert alert_management_alert_status_counts
container_expiration_policy service_desk_enabled service_desk_address
issue_status_counts terraform_states alert_management_integrations
container_repositories container_repositories_count
]
expect(described_class).to include_graphql_fields(*expected_fields)
......
......@@ -14,7 +14,7 @@ RSpec.describe 'getting container repositories in a group' do
let_it_be(:container_repositories) { [container_repository, container_repositories_delete_scheduled, container_repositories_delete_failed].flatten }
let_it_be(:container_expiration_policy) { project.container_expiration_policy }
let(:fields) do
let(:container_repositories_fields) do
<<~GQL
edges {
node {
......@@ -24,17 +24,25 @@ RSpec.describe 'getting container repositories in a group' do
GQL
end
let(:fields) do
<<~GQL
#{query_graphql_field('container_repositories', {}, container_repositories_fields)}
containerRepositoriesCount
GQL
end
let(:query) do
graphql_query_for(
'group',
{ 'fullPath' => group.full_path },
query_graphql_field('container_repositories', {}, fields)
fields
)
end
let(:user) { owner }
let(:variables) { {} }
let(:container_repositories_response) { graphql_data.dig('group', 'containerRepositories', 'edges') }
let(:container_repositories_count_response) { graphql_data.dig('group', 'containerRepositoriesCount') }
before do
group.add_owner(owner)
......@@ -101,7 +109,7 @@ RSpec.describe 'getting container repositories in a group' do
<<~GQL
query($path: ID!, $n: Int) {
group(fullPath: $path) {
containerRepositories(first: $n) { #{fields} }
containerRepositories(first: $n) { #{container_repositories_fields} }
}
}
GQL
......@@ -122,7 +130,7 @@ RSpec.describe 'getting container repositories in a group' do
<<~GQL
query($path: ID!, $name: String) {
group(fullPath: $path) {
containerRepositories(name: $name) { #{fields} }
containerRepositories(name: $name) { #{container_repositories_fields} }
}
}
GQL
......@@ -143,4 +151,10 @@ RSpec.describe 'getting container repositories in a group' do
expect(container_repositories_response.first.dig('node', 'id')).to eq(container_repository.to_global_id.to_s)
end
end
it 'returns the total count of container repositories' do
subject
expect(container_repositories_count_response).to eq(container_repositories.size)
end
end
......@@ -12,7 +12,7 @@ RSpec.describe 'getting container repositories in a project' do
let_it_be(:container_repositories) { [container_repository, container_repositories_delete_scheduled, container_repositories_delete_failed].flatten }
let_it_be(:container_expiration_policy) { project.container_expiration_policy }
let(:fields) do
let(:container_repositories_fields) do
<<~GQL
edges {
node {
......@@ -22,17 +22,25 @@ RSpec.describe 'getting container repositories in a project' do
GQL
end
let(:fields) do
<<~GQL
#{query_graphql_field('container_repositories', {}, container_repositories_fields)}
containerRepositoriesCount
GQL
end
let(:query) do
graphql_query_for(
'project',
{ 'fullPath' => project.full_path },
query_graphql_field('container_repositories', {}, fields)
fields
)
end
let(:user) { project.owner }
let(:variables) { {} }
let(:container_repositories_response) { graphql_data.dig('project', 'containerRepositories', 'edges') }
let(:container_repositories_count_response) { graphql_data.dig('project', 'containerRepositoriesCount') }
before do
stub_container_registry_config(enabled: true)
......@@ -100,7 +108,7 @@ RSpec.describe 'getting container repositories in a project' do
<<~GQL
query($path: ID!, $n: Int) {
project(fullPath: $path) {
containerRepositories(first: $n) { #{fields} }
containerRepositories(first: $n) { #{container_repositories_fields} }
}
}
GQL
......@@ -121,7 +129,7 @@ RSpec.describe 'getting container repositories in a project' do
<<~GQL
query($path: ID!, $name: String) {
project(fullPath: $path) {
containerRepositories(name: $name) { #{fields} }
containerRepositories(name: $name) { #{container_repositories_fields} }
}
}
GQL
......@@ -142,4 +150,10 @@ RSpec.describe 'getting container repositories in a project' do
expect(container_repositories_response.first.dig('node', 'id')).to eq(container_repository.to_global_id.to_s)
end
end
it 'returns the total count of container repositories' do
subject
expect(container_repositories_count_response).to eq(container_repositories.size)
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment