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
graphql_name 'Release'
description 'Represents a release'
connection_type_class(Types::CountableConnectionType)
authorize :read_release
alias_method :release, :object
......
---
title: Add total count to GraphQL release data
merge_request: 40147
author:
type: added
......@@ -13282,6 +13282,11 @@ type ReleaseAssets {
The connection type for Release.
"""
type ReleaseConnection {
"""
Total count of collection
"""
count: Int!
"""
A list of edges.
"""
......
......@@ -38872,6 +38872,24 @@
"name": "ReleaseConnection",
"description": "The connection type for Release.",
"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",
"description": "A list of edges.",
......@@ -14,6 +14,7 @@ RSpec.describe 'Query.project(fullPath).releases()' do
graphql_query_for(:project, { fullPath: project.full_path },
%{
releases {
count
nodes {
tagName
tagPath
......@@ -53,6 +54,20 @@ RSpec.describe 'Query.project(fullPath).releases()' do
stub_default_url_options(host: 'www.example.com')
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
describe 'repository-related fields' do
before do
......@@ -92,6 +107,8 @@ RSpec.describe 'Query.project(fullPath).releases()' do
)
end
end
it_behaves_like 'correct total count'
end
shared_examples 'no access to any repository-related fields' do
......@@ -119,6 +136,8 @@ RSpec.describe 'Query.project(fullPath).releases()' do
)
end
end
it_behaves_like 'correct total count'
end
# 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