Commit 711a584b authored by charlie ablett's avatar charlie ablett

Merge branch '214241-update-releases-page-to-use-graphql-endpoint' into 'master'

Add total count of project releases to GraphQL endpoint

See merge request gitlab-org/gitlab!40147
parents 9b967078 d913a6f7
...@@ -5,6 +5,8 @@ module Types ...@@ -5,6 +5,8 @@ module Types
graphql_name 'Release' graphql_name 'Release'
description 'Represents a release' description 'Represents a release'
connection_type_class(Types::CountableConnectionType)
authorize :read_release authorize :read_release
alias_method :release, :object alias_method :release, :object
......
---
title: Add total count to GraphQL release data
merge_request: 40147
author:
type: added
...@@ -13282,6 +13282,11 @@ type ReleaseAssets { ...@@ -13282,6 +13282,11 @@ type ReleaseAssets {
The connection type for Release. The connection type for Release.
""" """
type ReleaseConnection { type ReleaseConnection {
"""
Total count of collection
"""
count: Int!
""" """
A list of edges. A list of edges.
""" """
......
...@@ -38872,6 +38872,24 @@ ...@@ -38872,6 +38872,24 @@
"name": "ReleaseConnection", "name": "ReleaseConnection",
"description": "The connection type for Release.", "description": "The connection type for Release.",
"fields": [ "fields": [
{
"name": "count",
"description": "Total count of collection",
"args": [
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "Int",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{ {
"name": "edges", "name": "edges",
"description": "A list of edges.", "description": "A list of edges.",
...@@ -14,6 +14,7 @@ RSpec.describe 'Query.project(fullPath).releases()' do ...@@ -14,6 +14,7 @@ RSpec.describe 'Query.project(fullPath).releases()' do
graphql_query_for(:project, { fullPath: project.full_path }, graphql_query_for(:project, { fullPath: project.full_path },
%{ %{
releases { releases {
count
nodes { nodes {
tagName tagName
tagPath tagPath
...@@ -53,6 +54,20 @@ RSpec.describe 'Query.project(fullPath).releases()' do ...@@ -53,6 +54,20 @@ RSpec.describe 'Query.project(fullPath).releases()' do
stub_default_url_options(host: 'www.example.com') stub_default_url_options(host: 'www.example.com')
end end
shared_examples 'correct total count' do
let(:data) { graphql_data.dig('project', 'releases') }
before do
create_list(:release, 2, project: project)
post_query
end
it 'returns the total count' do
expect(data['count']).to eq(project.releases.count)
end
end
shared_examples 'full access to all repository-related fields' do shared_examples 'full access to all repository-related fields' do
describe 'repository-related fields' do describe 'repository-related fields' do
before do before do
...@@ -92,6 +107,8 @@ RSpec.describe 'Query.project(fullPath).releases()' do ...@@ -92,6 +107,8 @@ RSpec.describe 'Query.project(fullPath).releases()' do
) )
end end
end end
it_behaves_like 'correct total count'
end end
shared_examples 'no access to any repository-related fields' do shared_examples 'no access to any repository-related fields' do
...@@ -119,6 +136,8 @@ RSpec.describe 'Query.project(fullPath).releases()' do ...@@ -119,6 +136,8 @@ RSpec.describe 'Query.project(fullPath).releases()' do
) )
end end
end end
it_behaves_like 'correct total count'
end end
# editUrl is tested separately becuase its permissions # editUrl is tested separately becuase its permissions
......
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