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
3e94a58d
Commit
3e94a58d
authored
Nov 06, 2019
by
Brett Walker
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support sort RELATIVE_POSITION_ASC for issues
in GraphQL
parent
d4f6f704
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
77 additions
and
1 deletion
+77
-1
app/graphql/types/issue_sort_enum.rb
app/graphql/types/issue_sort_enum.rb
+1
-0
changelogs/unreleased/29713-graphql-add-issue-relative-position-sort-2.yml
...ased/29713-graphql-add-issue-relative-position-sort-2.yml
+5
-0
doc/api/graphql/reference/gitlab_schema.graphql
doc/api/graphql/reference/gitlab_schema.graphql
+5
-0
doc/api/graphql/reference/gitlab_schema.json
doc/api/graphql/reference/gitlab_schema.json
+6
-0
spec/graphql/resolvers/issues_resolver_spec.rb
spec/graphql/resolvers/issues_resolver_spec.rb
+13
-0
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
+46
-0
No files found.
app/graphql/types/issue_sort_enum.rb
View file @
3e94a58d
...
@@ -8,6 +8,7 @@ module Types
...
@@ -8,6 +8,7 @@ module Types
value
'DUE_DATE_ASC'
,
'Due date by ascending order'
,
value:
'due_date_asc'
value
'DUE_DATE_ASC'
,
'Due date by ascending order'
,
value:
'due_date_asc'
value
'DUE_DATE_DESC'
,
'Due date by descending order'
,
value:
'due_date_desc'
value
'DUE_DATE_DESC'
,
'Due date by descending order'
,
value:
'due_date_desc'
value
'RELATIVE_POSITION_ASC'
,
'Relative position by ascending order'
,
value:
'relative_position_asc'
end
end
# rubocop: enable Graphql/AuthorizeTypes
# rubocop: enable Graphql/AuthorizeTypes
end
end
changelogs/unreleased/29713-graphql-add-issue-relative-position-sort-2.yml
0 → 100644
View file @
3e94a58d
---
title
:
'
Graphql
query
for
issues
can
now
be
sorted
by
relative_position'
merge_request
:
19713
author
:
type
:
added
doc/api/graphql/reference/gitlab_schema.graphql
View file @
3e94a58d
...
@@ -2772,6 +2772,11 @@ enum IssueSort {
...
@@ -2772,6 +2772,11 @@ enum IssueSort {
"""
"""
DUE_DATE_DESC
DUE_DATE_DESC
"""
Relative
position
by
ascending
order
"""
RELATIVE_POSITION_ASC
"""
"""
Created
at
ascending
order
Created
at
ascending
order
"""
"""
...
...
doc/api/graphql/reference/gitlab_schema.json
View file @
3e94a58d
...
@@ -13631,6 +13631,12 @@
...
@@ -13631,6 +13631,12 @@
"description"
:
"Due date by descending order"
,
"description"
:
"Due date by descending order"
,
"isDeprecated"
:
false
,
"isDeprecated"
:
false
,
"deprecationReason"
:
null
"deprecationReason"
:
null
},
{
"name"
:
"RELATIVE_POSITION_ASC"
,
"description"
:
"Relative position by ascending order"
,
"isDeprecated"
:
false
,
"deprecationReason"
:
null
}
}
],
],
"possibleTypes"
:
null
"possibleTypes"
:
null
...
...
spec/graphql/resolvers/issues_resolver_spec.rb
View file @
3e94a58d
...
@@ -99,6 +99,19 @@ describe Resolvers::IssuesResolver do
...
@@ -99,6 +99,19 @@ describe Resolvers::IssuesResolver do
expect
(
resolve_issues
(
sort: :due_date_desc
)).
to
eq
[
due_issue1
,
due_issue3
,
due_issue4
,
due_issue2
]
expect
(
resolve_issues
(
sort: :due_date_desc
)).
to
eq
[
due_issue1
,
due_issue3
,
due_issue4
,
due_issue2
]
end
end
end
end
context
'when sorting by relative position'
do
let
(
:project
)
{
create
(
:project
)
}
let!
(
:relative_issue1
)
{
create
(
:issue
,
project:
project
,
relative_position:
2000
)
}
let!
(
:relative_issue2
)
{
create
(
:issue
,
project:
project
,
relative_position:
nil
)
}
let!
(
:relative_issue3
)
{
create
(
:issue
,
project:
project
,
relative_position:
1000
)
}
let!
(
:relative_issue4
)
{
create
(
:issue
,
project:
project
,
relative_position:
nil
)
}
it
'sorts issues ascending'
do
expect
(
resolve_issues
(
sort: :relative_position_asc
)).
to
eq
[
relative_issue3
,
relative_issue1
,
relative_issue4
,
relative_issue2
]
end
end
end
end
it
'returns issues user can see'
do
it
'returns issues user can see'
do
...
...
spec/graphql/types/issue_sort_enum_spec.rb
View file @
3e94a58d
...
@@ -8,6 +8,6 @@ describe GitlabSchema.types['IssueSort'] do
...
@@ -8,6 +8,6 @@ describe GitlabSchema.types['IssueSort'] do
it_behaves_like
'common sort values'
it_behaves_like
'common sort values'
it
'exposes all the existing issue sort values'
do
it
'exposes all the existing issue sort values'
do
expect
(
described_class
.
values
.
keys
).
to
include
(
*
%w[DUE_DATE_ASC DUE_DATE_DESC]
)
expect
(
described_class
.
values
.
keys
).
to
include
(
*
%w[DUE_DATE_ASC DUE_DATE_DESC
RELATIVE_POSITION_ASC
]
)
end
end
end
end
spec/requests/api/graphql/project/issues_spec.rb
View file @
3e94a58d
...
@@ -200,6 +200,52 @@ describe 'getting an issue list for a project' do
...
@@ -200,6 +200,52 @@ describe 'getting an issue list for a project' do
end
end
end
end
end
end
context
'when sorting by relative position'
do
let
(
:sort_project
)
{
create
(
:project
,
:public
)
}
let!
(
:relative_issue1
)
{
create
(
:issue
,
project:
sort_project
,
relative_position:
2000
)
}
let!
(
:relative_issue2
)
{
create
(
:issue
,
project:
sort_project
,
relative_position:
nil
)
}
let!
(
:relative_issue3
)
{
create
(
:issue
,
project:
sort_project
,
relative_position:
1000
)
}
let!
(
:relative_issue4
)
{
create
(
:issue
,
project:
sort_project
,
relative_position:
nil
)
}
let!
(
:relative_issue5
)
{
create
(
:issue
,
project:
sort_project
,
relative_position:
500
)
}
let
(
:params
)
{
'sort: RELATIVE_POSITION_ASC'
}
def
query
(
issue_params
=
params
)
graphql_query_for
(
'project'
,
{
'fullPath'
=>
sort_project
.
full_path
},
"issues(
#{
issue_params
}
) { pageInfo { endCursor} edges { node { iid dueDate } } }"
)
end
before
do
post_graphql
(
query
,
current_user:
current_user
)
end
it_behaves_like
'a working graphql query'
context
'when ascending'
do
it
'sorts issues'
do
expect
(
grab_iids
).
to
eq
[
relative_issue5
.
iid
,
relative_issue3
.
iid
,
relative_issue1
.
iid
,
relative_issue4
.
iid
,
relative_issue2
.
iid
]
end
context
'when paginating'
do
let
(
:params
)
{
'sort: RELATIVE_POSITION_ASC, first: 2'
}
it
'sorts issues'
do
expect
(
grab_iids
).
to
eq
[
relative_issue5
.
iid
,
relative_issue3
.
iid
]
cursored_query
=
query
(
"sort: RELATIVE_POSITION_ASC, after:
\"
#{
end_cursor
}
\"
"
)
post_graphql
(
cursored_query
,
current_user:
current_user
)
response_data
=
JSON
.
parse
(
response
.
body
)[
'data'
][
'project'
][
'issues'
][
'edges'
]
expect
(
grab_iids
(
response_data
)).
to
eq
[
relative_issue1
.
iid
,
relative_issue4
.
iid
,
relative_issue2
.
iid
]
end
end
end
end
end
end
def
grab_iids
(
data
=
issues_data
)
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