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
graphql_name 'Package'
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
field :id, ::Types::GlobalIDType[::Packages::Package], null: false,
......
......@@ -6510,6 +6510,7 @@ The connection type for [`Package`](#package).
| 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="packageconnectionnodes"></a>`nodes` | [`[Package]`](#package) | A list of nodes. |
| <a id="packageconnectionpageinfo"></a>`pageInfo` | [`PageInfo!`](#pageinfo) | Information to aid in pagination. |
......
......@@ -50,6 +50,7 @@
"type": "object",
"additionalProperties": false,
"properties": {
"count": { "type": "integer" },
"pageInfo": { "type": "object" },
"edges": { "type": "array" },
"nodes": { "type": "array" }
......@@ -72,6 +73,7 @@
"type": "object",
"additionalProperties": false,
"properties": {
"count": { "type": "integer" },
"pageInfo": { "type": "object" },
"edges": { "type": "array" },
"nodes": { "type": "array" }
......@@ -91,6 +93,7 @@
"type": "object",
"additionalProperties": false,
"properties": {
"count": { "type": "integer" },
"pageInfo": { "type": "object" },
"edges": { "type": "array" },
"nodes": { "type": "array" }
......@@ -106,6 +109,7 @@
"properties": {
"pageInfo": { "type": "object" },
"edges": { "type": "array" },
"count": { "type": "integer" },
"nodes": {
"type": "array",
"items": {
......
......@@ -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(:target_shas) { graphql_data_at(resource_type, :packages, :nodes, :metadata, :target_sha) }
let(:packages) { graphql_data_at(resource_type, :packages, :nodes) }
let(:packages_count) { graphql_data_at(resource_type, :packages, :count) }
let(:fields) do
<<~QUERY
count
nodes {
#{all_graphql_fields_for('packages'.classify, excluded: ['project'])}
metadata { #{query_graphql_fragment('ComposerMetadata')} }
......@@ -55,6 +57,10 @@ RSpec.shared_examples 'group and project packages query' do
it 'deals with metadata' do
expect(target_shas).to contain_exactly(composer_metadatum.target_sha)
end
it 'returns the count of the packages' do
expect(packages_count).to eq(4)
end
end
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