Commit 4fc8d33a authored by Vasilii Iakliushin's avatar Vasilii Iakliushin

Merge branch '330846-add-packages-count-to-graphql' into 'master'

Add packagesCount to project and group type

See merge request gitlab-org/gitlab!70958
parents 231497bb 843a9205
...@@ -6,6 +6,8 @@ module Types ...@@ -6,6 +6,8 @@ module Types
graphql_name 'Package' graphql_name 'Package'
description 'Represents a package in the Package Registry. Note that this type is in beta and susceptible to changes' description 'Represents a package in the Package Registry. Note that this type is in beta and susceptible to changes'
connection_type_class(Types::CountableConnectionType)
authorize :read_package authorize :read_package
field :id, ::Types::GlobalIDType[::Packages::Package], null: false, field :id, ::Types::GlobalIDType[::Packages::Package], null: false,
......
...@@ -6510,6 +6510,7 @@ The connection type for [`Package`](#package). ...@@ -6510,6 +6510,7 @@ The connection type for [`Package`](#package).
| Name | Type | Description | | Name | Type | Description |
| ---- | ---- | ----------- | | ---- | ---- | ----------- |
| <a id="packageconnectioncount"></a>`count` | [`Int!`](#int) | Total count of collection. |
| <a id="packageconnectionedges"></a>`edges` | [`[PackageEdge]`](#packageedge) | A list of edges. | | <a id="packageconnectionedges"></a>`edges` | [`[PackageEdge]`](#packageedge) | A list of edges. |
| <a id="packageconnectionnodes"></a>`nodes` | [`[Package]`](#package) | A list of nodes. | | <a id="packageconnectionnodes"></a>`nodes` | [`[Package]`](#package) | A list of nodes. |
| <a id="packageconnectionpageinfo"></a>`pageInfo` | [`PageInfo!`](#pageinfo) | Information to aid in pagination. | | <a id="packageconnectionpageinfo"></a>`pageInfo` | [`PageInfo!`](#pageinfo) | Information to aid in pagination. |
......
...@@ -50,6 +50,7 @@ ...@@ -50,6 +50,7 @@
"type": "object", "type": "object",
"additionalProperties": false, "additionalProperties": false,
"properties": { "properties": {
"count": { "type": "integer" },
"pageInfo": { "type": "object" }, "pageInfo": { "type": "object" },
"edges": { "type": "array" }, "edges": { "type": "array" },
"nodes": { "type": "array" } "nodes": { "type": "array" }
...@@ -72,6 +73,7 @@ ...@@ -72,6 +73,7 @@
"type": "object", "type": "object",
"additionalProperties": false, "additionalProperties": false,
"properties": { "properties": {
"count": { "type": "integer" },
"pageInfo": { "type": "object" }, "pageInfo": { "type": "object" },
"edges": { "type": "array" }, "edges": { "type": "array" },
"nodes": { "type": "array" } "nodes": { "type": "array" }
...@@ -91,6 +93,7 @@ ...@@ -91,6 +93,7 @@
"type": "object", "type": "object",
"additionalProperties": false, "additionalProperties": false,
"properties": { "properties": {
"count": { "type": "integer" },
"pageInfo": { "type": "object" }, "pageInfo": { "type": "object" },
"edges": { "type": "array" }, "edges": { "type": "array" },
"nodes": { "type": "array" } "nodes": { "type": "array" }
...@@ -106,6 +109,7 @@ ...@@ -106,6 +109,7 @@
"properties": { "properties": {
"pageInfo": { "type": "object" }, "pageInfo": { "type": "object" },
"edges": { "type": "array" }, "edges": { "type": "array" },
"count": { "type": "integer" },
"nodes": { "nodes": {
"type": "array", "type": "array",
"items": { "items": {
......
...@@ -17,9 +17,11 @@ RSpec.shared_examples 'group and project packages query' do ...@@ -17,9 +17,11 @@ RSpec.shared_examples 'group and project packages query' do
let(:package_names) { graphql_data_at(resource_type, :packages, :nodes, :name) } let(:package_names) { graphql_data_at(resource_type, :packages, :nodes, :name) }
let(:target_shas) { graphql_data_at(resource_type, :packages, :nodes, :metadata, :target_sha) } let(:target_shas) { graphql_data_at(resource_type, :packages, :nodes, :metadata, :target_sha) }
let(:packages) { graphql_data_at(resource_type, :packages, :nodes) } let(:packages) { graphql_data_at(resource_type, :packages, :nodes) }
let(:packages_count) { graphql_data_at(resource_type, :packages, :count) }
let(:fields) do let(:fields) do
<<~QUERY <<~QUERY
count
nodes { nodes {
#{all_graphql_fields_for('packages'.classify, excluded: ['project'])} #{all_graphql_fields_for('packages'.classify, excluded: ['project'])}
metadata { #{query_graphql_fragment('ComposerMetadata')} } metadata { #{query_graphql_fragment('ComposerMetadata')} }
...@@ -55,6 +57,10 @@ RSpec.shared_examples 'group and project packages query' do ...@@ -55,6 +57,10 @@ RSpec.shared_examples 'group and project packages query' do
it 'deals with metadata' do it 'deals with metadata' do
expect(target_shas).to contain_exactly(composer_metadatum.target_sha) expect(target_shas).to contain_exactly(composer_metadatum.target_sha)
end end
it 'returns the count of the packages' do
expect(packages_count).to eq(4)
end
end end
context 'when the user does not have access to the resource' do context 'when the user does not have access to the resource' do
......
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