diff --git a/doc/api/graphql/reference/index.md b/doc/api/graphql/reference/index.md index 7693d3647452a41f54607cf37d08943a683216b0..bcfd6d44cc1abaf23fed3b149234053b8b4fe78f 100644 --- a/doc/api/graphql/reference/index.md +++ b/doc/api/graphql/reference/index.md @@ -6093,6 +6093,7 @@ The connection type for [`BoardEpic`](#boardepic). | Name | Type | Description | | ---- | ---- | ----------- | +| <a id="boardepicconnectioncount"></a>`count` | [`Int!`](#int) | Total count of collection. | | <a id="boardepicconnectionedges"></a>`edges` | [`[BoardEpicEdge]`](#boardepicedge) | A list of edges. | | <a id="boardepicconnectionnodes"></a>`nodes` | [`[BoardEpic]`](#boardepic) | A list of nodes. | | <a id="boardepicconnectionpageinfo"></a>`pageInfo` | [`PageInfo!`](#pageinfo) | Information to aid in pagination. | @@ -7265,6 +7266,7 @@ The connection type for [`Epic`](#epic). | Name | Type | Description | | ---- | ---- | ----------- | +| <a id="epicconnectioncount"></a>`count` | [`Int!`](#int) | Total count of collection. | | <a id="epicconnectionedges"></a>`edges` | [`[EpicEdge]`](#epicedge) | A list of edges. | | <a id="epicconnectionnodes"></a>`nodes` | [`[Epic]`](#epic) | A list of nodes. | | <a id="epicconnectionpageinfo"></a>`pageInfo` | [`PageInfo!`](#pageinfo) | Information to aid in pagination. | diff --git a/ee/app/graphql/types/epic_type.rb b/ee/app/graphql/types/epic_type.rb index 3de10ed7eaee033bd337c7097f4320b182ada0ce..eb78e2e63f80012c73581532a9df9fc97735298c 100644 --- a/ee/app/graphql/types/epic_type.rb +++ b/ee/app/graphql/types/epic_type.rb @@ -5,6 +5,8 @@ class EpicType < BaseObject graphql_name 'Epic' description 'Represents an epic' + connection_type_class(Types::CountableConnectionType) + include ::Gitlab::Graphql::Aggregations::Epics::Constants accepts ::Epic diff --git a/ee/spec/graphql/types/epic_connection_type_spec.rb b/ee/spec/graphql/types/epic_connection_type_spec.rb new file mode 100644 index 0000000000000000000000000000000000000000..9cf88cf948484e6ee44768cd4fc00ea9e9acbd98 --- /dev/null +++ b/ee/spec/graphql/types/epic_connection_type_spec.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe GitlabSchema.types['EpicConnection'] do + it 'has the expected fields' do + expected_fields = %i[edges nodes count pageInfo] + + expect(described_class).to have_graphql_fields(*expected_fields) + end +end diff --git a/ee/spec/requests/api/graphql/epics/epic_resolver_spec.rb b/ee/spec/requests/api/graphql/epics/epic_resolver_spec.rb index badb2cdd5ed84744b083dd29194131c6e3c051de..3163630cb1cef75dc641c8c7c30017a57606c898 100644 --- a/ee/spec/requests/api/graphql/epics/epic_resolver_spec.rb +++ b/ee/spec/requests/api/graphql/epics/epic_resolver_spec.rb @@ -201,6 +201,48 @@ def execute_query end end + describe 'query for epics including their count' do + let(:query) do + <<~QUERY + query groupEpics($groupPath: ID!, $firstPageSize: Int) { + group(fullPath: $groupPath) { + id + epics( + first: $firstPageSize + ) { + count + nodes { + id + iid + } + } + } + } + QUERY + end + + before do + create_list(:epic, 10, group: group) + end + + it 'returns epics total count' do + page_size = 5 + + post_graphql( + query, + current_user: user, + variables: { + groupPath: group.full_path, + firstPageSize: page_size + } + ) + + epics = graphql_dig_at(graphql_data, :group, :epics) + expect(epics['nodes'].size).to eq(page_size) + expect(epics['count']).to eq(10) + end + end + def query_epics_with_events(number) epics_field = <<~NODE epics {