Commit d913a6f7 authored by Nathan Friend's avatar Nathan Friend Committed by charlie ablett

Add total count to GraphQL release data

This commit allows the GraphQL endpoint to return the total number of
releases in a project.
parent 3d9b5f1f
......@@ -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
......@@ -13109,6 +13109,11 @@ type ReleaseAssets {
The connection type for Release.
"""
type ReleaseConnection {
"""
Total count of collection
"""
count: Int!
"""
A list of edges.
"""
......
......@@ -38297,6 +38297,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