Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
d4f4153f
Commit
d4f4153f
authored
Oct 16, 2020
by
Pavel Shutsin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add issues collection weight to GraphQL
User not can query for aggregated weight of issues under selection
parent
2c780291
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
130 additions
and
3 deletions
+130
-3
app/graphql/types/countable_connection_type.rb
app/graphql/types/countable_connection_type.rb
+1
-1
app/graphql/types/issue_connection_type.rb
app/graphql/types/issue_connection_type.rb
+9
-0
app/graphql/types/issue_type.rb
app/graphql/types/issue_type.rb
+1
-1
doc/api/graphql/reference/gitlab_schema.graphql
doc/api/graphql/reference/gitlab_schema.graphql
+10
-0
doc/api/graphql/reference/gitlab_schema.json
doc/api/graphql/reference/gitlab_schema.json
+36
-0
ee/app/graphql/ee/types/issue_connection_type.rb
ee/app/graphql/ee/types/issue_connection_type.rb
+33
-0
ee/changelogs/unreleased/268222-add-issues-weight-to-graphql.yml
...gelogs/unreleased/268222-add-issues-weight-to-graphql.yml
+5
-0
ee/spec/graphql/types/issue_connection_type_spec.rb
ee/spec/graphql/types/issue_connection_type_spec.rb
+34
-0
spec/graphql/types/countable_connection_type_spec.rb
spec/graphql/types/countable_connection_type_spec.rb
+1
-1
No files found.
app/graphql/types/countable_connection_type.rb
View file @
d4f4153f
...
...
@@ -3,7 +3,7 @@
module
Types
# rubocop: disable Graphql/AuthorizeTypes
class
CountableConnectionType
<
GraphQL
::
Types
::
Relay
::
BaseConnection
field
:count
,
Integer
,
null:
false
,
field
:count
,
GraphQL
::
INT_TYPE
,
null:
false
,
description:
'Total count of collection'
def
count
...
...
app/graphql/types/issue_connection_type.rb
0 → 100644
View file @
d4f4153f
# frozen_string_literal: true
module
Types
# rubocop: disable Graphql/AuthorizeTypes
class
IssueConnectionType
<
CountableConnectionType
end
end
Types
::
IssueConnectionType
.
prepend_if_ee
(
'::EE::Types::IssueConnectionType'
)
app/graphql/types/issue_type.rb
View file @
d4f4153f
...
...
@@ -4,7 +4,7 @@ module Types
class
IssueType
<
BaseObject
graphql_name
'Issue'
connection_type_class
(
Types
::
Countabl
eConnectionType
)
connection_type_class
(
Types
::
Issu
eConnectionType
)
implements
(
Types
::
Notes
::
NoteableType
)
implements
(
Types
::
CurrentUserTodos
)
...
...
doc/api/graphql/reference/gitlab_schema.graphql
View file @
d4f4153f
...
...
@@ -7036,6 +7036,11 @@ type EpicIssueConnection {
Information
to
aid
in
pagination
.
"""
pageInfo
:
PageInfo
!
"""
Total
weight
of
issues
collection
"""
weight
:
Int
!
}
"""
...
...
@@ -9234,6 +9239,11 @@ type IssueConnection {
Information
to
aid
in
pagination
.
"""
pageInfo
:
PageInfo
!
"""
Total
weight
of
issues
collection
"""
weight
:
Int
!
}
"""
...
...
doc/api/graphql/reference/gitlab_schema.json
View file @
d4f4153f
...
...
@@ -19387,6 +19387,24 @@
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "weight",
"description": "Total weight of issues collection",
"args": [
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "Int",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
}
],
"inputFields": null,
...
...
@@ -25159,6 +25177,24 @@
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "weight",
"description": "Total weight of issues collection",
"args": [
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "Int",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
}
],
"inputFields": null,
ee/app/graphql/ee/types/issue_connection_type.rb
0 → 100644
View file @
d4f4153f
# frozen_string_literal: true
module
EE
module
Types
module
IssueConnectionType
extend
ActiveSupport
::
Concern
prepended
do
field
:weight
,
GraphQL
::
INT_TYPE
,
null:
false
,
description:
'Total weight of issues collection'
end
def
weight
# rubocop: disable CodeReuse/ActiveRecord
relation
=
object
.
items
if
relation
.
respond_to?
(
:reorder
)
relation
=
relation
.
reorder
(
nil
)
result
=
relation
.
sum
(
:weight
)
if
relation
.
try
(
:group_values
)
&
.
present?
result
.
values
.
sum
else
result
end
else
relation
.
map
(
&
:weight
).
compact
.
sum
end
# rubocop: enable CodeReuse/ActiveRecord
end
end
end
end
ee/changelogs/unreleased/268222-add-issues-weight-to-graphql.yml
0 → 100644
View file @
d4f4153f
---
title
:
Add issues collection weight to GraphQL
merge_request
:
45415
author
:
type
:
added
ee/spec/graphql/types/issue_connection_type_spec.rb
0 → 100644
View file @
d4f4153f
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
GitlabSchema
.
types
[
'IssueConnection'
]
do
describe
'#weight'
do
subject
(
:response
)
{
GitlabSchema
.
execute
(
query
,
context:
{
current_user:
current_user
})
}
let
(
:query
)
do
%(
query{
project(fullPath:"#{project.full_path}"){
issues{
weight
}
}
}
)
end
let_it_be
(
:project
)
{
create
:project
,
:public
}
let_it_be
(
:current_user
)
{
create
:admin
}
before
do
create
:issue
,
project:
project
,
weight:
2
create
:issue
,
project:
project
,
weight:
7
create
:issue
,
project:
project
,
weight:
nil
end
it
'returns sum of all weights'
do
expect
(
response
.
dig
(
*
%w[data project issues weight]
)).
to
eq
9
end
end
end
spec/graphql/types/countable_connection_type_spec.rb
View file @
d4f4153f
...
...
@@ -2,7 +2,7 @@
require
'spec_helper'
RSpec
.
describe
GitlabSchema
.
types
[
'
Issue
Connection'
]
do
RSpec
.
describe
GitlabSchema
.
types
[
'
MergeRequest
Connection'
]
do
it
'has the expected fields'
do
expected_fields
=
%i[count page_info edges nodes]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment