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
0eedf4a3
Commit
0eedf4a3
authored
Apr 29, 2020
by
Brett Walker
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow sorting of issues with milestone_due_asc
in GraphQL
parent
59e842e5
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
95 additions
and
4 deletions
+95
-4
app/graphql/resolvers/issues_resolver.rb
app/graphql/resolvers/issues_resolver.rb
+3
-1
app/graphql/types/issuable_sort_enum.rb
app/graphql/types/issuable_sort_enum.rb
+2
-0
changelogs/unreleased/38296-graphql-add-milestone_due_asc-sort-for-issuables.yml
...8296-graphql-add-milestone_due_asc-sort-for-issuables.yml
+5
-0
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
+12
-0
spec/graphql/resolvers/issues_resolver_spec.rb
spec/graphql/resolvers/issues_resolver_spec.rb
+17
-0
spec/graphql/types/issuable_sort_enum_spec.rb
spec/graphql/types/issuable_sort_enum_spec.rb
+5
-1
spec/graphql/types/issue_sort_enum_spec.rb
spec/graphql/types/issue_sort_enum_spec.rb
+1
-1
spec/requests/api/graphql/project/issues_spec.rb
spec/requests/api/graphql/project/issues_spec.rb
+40
-1
No files found.
app/graphql/resolvers/issues_resolver.rb
View file @
0eedf4a3
...
...
@@ -52,7 +52,9 @@ module Resolvers
type
Types
::
IssueType
,
null:
true
NON_STABLE_CURSOR_SORTS
=
%i[priority_asc priority_desc label_priority_asc label_priority_desc]
.
freeze
NON_STABLE_CURSOR_SORTS
=
%i[priority_asc priority_desc
label_priority_asc label_priority_desc
milestone_due_asc milestone_due_desc]
.
freeze
def
resolve
(
**
args
)
# The project could have been loaded in batch by `BatchLoader`.
...
...
app/graphql/types/issuable_sort_enum.rb
View file @
0eedf4a3
...
...
@@ -9,5 +9,7 @@ module Types
value
'PRIORITY_DESC'
,
'Priority by descending order'
,
value: :priority_desc
value
'LABEL_PRIORITY_ASC'
,
'Label priority by ascending order'
,
value: :label_priority_asc
value
'LABEL_PRIORITY_DESC'
,
'Label priority by descending order'
,
value: :label_priority_desc
value
'MILESTONE_DUE_ASC'
,
'Milestone due date by ascending order'
,
value: :milestone_due_asc
value
'MILESTONE_DUE_DESC'
,
'Milestone due date by descending order'
,
value: :milestone_due_desc
end
end
changelogs/unreleased/38296-graphql-add-milestone_due_asc-sort-for-issuables.yml
0 → 100644
View file @
0eedf4a3
---
title
:
GraphQL issue queries can now be sorted by milestone due date
merge_request
:
29992
author
:
type
:
added
doc/api/graphql/reference/gitlab_schema.graphql
View file @
0eedf4a3
...
...
@@ -4677,6 +4677,16 @@ enum IssueSort {
"""
LABEL_PRIORITY_DESC
"""
Milestone
due
date
by
ascending
order
"""
MILESTONE_DUE_ASC
"""
Milestone
due
date
by
descending
order
"""
MILESTONE_DUE_DESC
"""
Priority
by
ascending
order
"""
...
...
doc/api/graphql/reference/gitlab_schema.json
View file @
0eedf4a3
...
...
@@ -13272,6 +13272,18 @@
"isDeprecated"
:
false
,
"deprecationReason"
:
null
},
{
"name"
:
"MILESTONE_DUE_ASC"
,
"description"
:
"Milestone due date by ascending order"
,
"isDeprecated"
:
false
,
"deprecationReason"
:
null
},
{
"name"
:
"MILESTONE_DUE_DESC"
,
"description"
:
"Milestone due date by descending order"
,
"isDeprecated"
:
false
,
"deprecationReason"
:
null
},
{
"name"
:
"DUE_DATE_ASC"
,
"description"
:
"Due date by ascending order"
,
...
...
spec/graphql/resolvers/issues_resolver_spec.rb
View file @
0eedf4a3
...
...
@@ -190,6 +190,23 @@ describe Resolvers::IssuesResolver do
expect
(
resolve_issues
(
sort: :label_priority_desc
).
items
).
to
eq
([
label_issue2
,
label_issue3
,
label_issue1
,
label_issue4
])
end
end
context
'when sorting by milestone due date'
do
let_it_be
(
:project
)
{
create
(
:project
)
}
let_it_be
(
:early_milestone
)
{
create
(
:milestone
,
project:
project
,
due_date:
10
.
days
.
from_now
)
}
let_it_be
(
:late_milestone
)
{
create
(
:milestone
,
project:
project
,
due_date:
30
.
days
.
from_now
)
}
let_it_be
(
:milestone_issue1
)
{
create
(
:issue
,
project:
project
)
}
let_it_be
(
:milestone_issue2
)
{
create
(
:issue
,
project:
project
,
milestone:
early_milestone
)
}
let_it_be
(
:milestone_issue3
)
{
create
(
:issue
,
project:
project
,
milestone:
late_milestone
)
}
it
'sorts issues ascending'
do
expect
(
resolve_issues
(
sort: :milestone_due_asc
).
items
).
to
eq
([
milestone_issue2
,
milestone_issue3
,
milestone_issue1
])
end
it
'sorts issues descending'
do
expect
(
resolve_issues
(
sort: :milestone_due_desc
).
items
).
to
eq
([
milestone_issue3
,
milestone_issue2
,
milestone_issue1
])
end
end
end
it
'returns issues user can see'
do
...
...
spec/graphql/types/issuable_sort_enum_spec.rb
View file @
0eedf4a3
...
...
@@ -6,6 +6,10 @@ describe Types::IssuableSortEnum do
it
{
expect
(
described_class
.
graphql_name
).
to
eq
(
'IssuableSort'
)
}
it
'exposes all the existing issuable sort values'
do
expect
(
described_class
.
values
.
keys
).
to
include
(
*
%w[PRIORITY_ASC PRIORITY_DESC]
)
expect
(
described_class
.
values
.
keys
).
to
include
(
*
%w[PRIORITY_ASC PRIORITY_DESC
LABEL_PRIORITY_ASC LABEL_PRIORITY_DESC
MILESTONE_DUE_ASC MILESTONE_DUE_DESC
]
)
end
end
spec/graphql/types/issue_sort_enum_spec.rb
View file @
0eedf4a3
...
...
@@ -9,7 +9,7 @@ describe GitlabSchema.types['IssueSort'] do
it
'exposes all the existing issue sort values'
do
expect
(
described_class
.
values
.
keys
).
to
include
(
*
%w[DUE_DATE_ASC DUE_DATE_DESC RELATIVE_POSITION_ASC
LABEL_PRIORITY_ASC LABEL_PRIORITY_DESC
]
*
%w[DUE_DATE_ASC DUE_DATE_DESC RELATIVE_POSITION_ASC]
)
end
end
spec/requests/api/graphql/project/issues_spec.rb
View file @
0eedf4a3
...
...
@@ -120,6 +120,20 @@ describe 'getting an issue list for a project' do
describe
'sorting and pagination'
do
let
(
:start_cursor
)
{
graphql_data
[
'project'
][
'issues'
][
'pageInfo'
][
'startCursor'
]
}
let
(
:end_cursor
)
{
graphql_data
[
'project'
][
'issues'
][
'pageInfo'
][
'endCursor'
]
}
let
(
:data_path
)
{
[
:project
,
:issues
]
}
def
pagination_query
(
params
,
page_info
)
graphql_query_for
(
'project'
,
{
'fullPath'
=>
sort_project
.
full_path
},
"issues(
#{
params
}
) {
#{
page_info
}
edges { node { iid dueDate } } }"
)
end
def
pagination_results_data
(
data
)
data
.
map
{
|
issue
|
issue
.
dig
(
'node'
,
'iid'
).
to_i
}
end
context
'when sorting by due date'
do
let_it_be
(
:sort_project
)
{
create
(
:project
,
:public
)
}
...
...
@@ -387,6 +401,31 @@ describe 'getting an issue list for a project' do
end
end
end
context
'when sorting by milestone due date'
do
let_it_be
(
:sort_project
)
{
create
(
:project
,
:public
)
}
let_it_be
(
:early_milestone
)
{
create
(
:milestone
,
project:
sort_project
,
due_date:
10
.
days
.
from_now
)
}
let_it_be
(
:late_milestone
)
{
create
(
:milestone
,
project:
sort_project
,
due_date:
30
.
days
.
from_now
)
}
let_it_be
(
:milestone_issue1
)
{
create
(
:issue
,
project:
sort_project
)
}
let_it_be
(
:milestone_issue2
)
{
create
(
:issue
,
project:
sort_project
,
milestone:
early_milestone
)
}
let_it_be
(
:milestone_issue3
)
{
create
(
:issue
,
project:
sort_project
,
milestone:
late_milestone
)
}
context
'when ascending'
do
it_behaves_like
'sorted paginated query'
do
let
(
:sort_param
)
{
'MILESTONE_DUE_ASC'
}
let
(
:first_param
)
{
2
}
let
(
:expected_results
)
{
[
milestone_issue2
.
iid
,
milestone_issue3
.
iid
,
milestone_issue1
.
iid
]
}
end
end
context
'when descending'
do
it_behaves_like
'sorted paginated query'
do
let
(
:sort_param
)
{
'MILESTONE_DUE_DESC'
}
let
(
:first_param
)
{
2
}
let
(
:expected_results
)
{
[
milestone_issue3
.
iid
,
milestone_issue2
.
iid
,
milestone_issue1
.
iid
]
}
end
end
end
end
def
grab_iids
(
data
=
issues_data
)
...
...
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