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
cc1dcae0
Commit
cc1dcae0
authored
Jul 31, 2020
by
charlie ablett
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle count of grouped queries
- add board issue specs - add changelog
parent
73540f95
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
177 additions
and
2 deletions
+177
-2
app/graphql/resolvers/board_list_issues_resolver.rb
app/graphql/resolvers/board_list_issues_resolver.rb
+1
-1
app/graphql/types/issuable_connection_type.rb
app/graphql/types/issuable_connection_type.rb
+7
-1
changelogs/unreleased/swimlanes-expose-issues.yml
changelogs/unreleased/swimlanes-expose-issues.yml
+5
-0
spec/graphql/resolvers/board_list_issues_resolver_spec.rb
spec/graphql/resolvers/board_list_issues_resolver_spec.rb
+63
-0
spec/requests/api/graphql/boards/board_list_issues_query_spec.rb
...quests/api/graphql/boards/board_list_issues_query_spec.rb
+101
-0
No files found.
app/graphql/resolvers/board_list_issues_resolver.rb
View file @
cc1dcae0
...
...
@@ -9,7 +9,7 @@ module Resolvers
def
resolve
(
**
args
)
# rubocop: disable CodeReuse/ActiveRecord
service
=
Boards
::
Issues
::
ListService
.
new
(
list
.
board
.
resource_parent
,
context
[
:current_user
],
{
board_id:
list
.
board
.
id
,
id:
list
.
id
})
service
.
execute
.
reorder
(
"
relative_position A
SC"
)
service
.
execute
.
reorder
(
"
issues.relative_position ASC"
).
order
(
"issues.id DE
SC"
)
# rubocop: enable CodeReuse/ActiveRecord
end
end
...
...
app/graphql/types/issuable_connection_type.rb
View file @
cc1dcae0
...
...
@@ -7,7 +7,13 @@ module Types
description:
'Total count of collection'
def
count
object
.
items
.
size
relation
=
object
.
items
if
relation
.
try
(
:group_values
)
&
.
present?
relation
.
size
.
keys
.
size
else
relation
.
size
end
end
end
end
changelogs/unreleased/swimlanes-expose-issues.yml
0 → 100644
View file @
cc1dcae0
---
title
:
Expose board list issues via GraphQL
merge_request
:
36259
author
:
type
:
added
spec/graphql/resolvers/board_list_issues_resolver_spec.rb
0 → 100644
View file @
cc1dcae0
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
Resolvers
::
BoardListIssuesResolver
do
include
GraphqlHelpers
let_it_be
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:unauth_user
)
{
create
(
:user
)
}
let_it_be
(
:user_project
)
{
create
(
:project
,
creator_id:
user
.
id
,
namespace:
user
.
namespace
)
}
let_it_be
(
:group
)
{
create
(
:group
,
:private
)
}
shared_examples_for
'group and project board list issues resolver'
do
let!
(
:board
)
{
create
(
:board
,
resource_parent:
board_parent
)
}
before
do
board_parent
.
add_developer
(
user
)
end
# auth is handled by the parent object
context
'when authorized'
do
let!
(
:list
)
{
create
(
:list
,
board:
board
,
label:
label
)
}
let!
(
:issue1
)
{
create
(
:issue
,
project:
project
,
labels:
[
label
],
relative_position:
10
,
id:
44
)
}
let!
(
:issue2
)
{
create
(
:issue
,
project:
project
,
labels:
[
label
],
relative_position:
12
,
id:
45
)
}
let!
(
:issue3
)
{
create
(
:issue
,
project:
project
,
labels:
[
label
],
relative_position:
10
,
id:
46
)
}
it
'calls Boards::Issues::ListService with the correct arguments'
do
expect
(
Boards
::
Issues
::
ListService
).
to
receive
(
:new
).
with
(
board_parent
,
user
,
{
board_id:
board
.
id
,
id:
list
.
id
}).
and_call_original
resolve_board_list_issues
end
it
'returns the issues in the correct order'
do
# by relative_position and then ID
issues
=
resolve_board_list_issues
expect
(
issues
.
map
(
&
:id
)).
to
eq
[
issue3
.
id
,
issue1
.
id
,
issue2
.
id
]
end
end
end
describe
'#resolve'
do
context
'when project boards'
do
let
(
:board_parent
)
{
user_project
}
let!
(
:label
)
{
create
(
:label
,
project:
project
,
name:
'project label'
)
}
let
(
:project
)
{
user_project
}
it_behaves_like
'group and project board list issues resolver'
end
context
'when group boards'
do
let
(
:board_parent
)
{
group
}
let!
(
:label
)
{
create
(
:group_label
,
group:
group
,
name:
'group label'
)
}
let!
(
:project
)
{
create
(
:project
,
:private
,
group:
group
)
}
it_behaves_like
'group and project board list issues resolver'
end
end
def
resolve_board_list_issues
(
args:
{},
current_user:
user
)
resolve
(
described_class
,
obj:
list
,
args:
args
,
ctx:
{
current_user:
current_user
})
end
end
spec/requests/api/graphql/boards/board_list_issues_query_spec.rb
0 → 100644
View file @
cc1dcae0
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
'get board lists'
do
include
GraphqlHelpers
let_it_be
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:unauth_user
)
{
create
(
:user
)
}
let_it_be
(
:project
)
{
create
(
:project
,
creator_id:
user
.
id
,
namespace:
user
.
namespace
)
}
let_it_be
(
:group
)
{
create
(
:group
,
:private
)
}
let_it_be
(
:project_label
)
{
create
(
:label
,
project:
project
,
name:
'Development'
)
}
let_it_be
(
:project_label2
)
{
create
(
:label
,
project:
project
,
name:
'Testing'
)
}
let_it_be
(
:group_label
)
{
create
(
:group_label
,
group:
group
,
name:
'Development'
)
}
let_it_be
(
:group_label2
)
{
create
(
:group_label
,
group:
group
,
name:
'Testing'
)
}
let
(
:params
)
{
''
}
let
(
:board
)
{
}
let
(
:board_parent_type
)
{
board_parent
.
class
.
to_s
.
downcase
}
let
(
:board_data
)
{
graphql_data
[
board_parent_type
][
'boards'
][
'nodes'
][
0
]
}
let
(
:lists_data
)
{
board_data
[
'lists'
][
'nodes'
][
0
]
}
let
(
:issues_data
)
{
lists_data
[
'issues'
][
'nodes'
]
}
def
query
(
list_params
=
params
)
graphql_query_for
(
board_parent_type
,
{
'fullPath'
=>
board_parent
.
full_path
},
<<~
BOARDS
boards(first: 1) {
nodes {
lists {
nodes {
issues {
count
nodes {
#{
all_graphql_fields_for
(
'issues'
.
classify
)
}
}
}
}
}
}
}
BOARDS
)
end
def
issue_titles
issues_data
.
map
{
|
i
|
i
[
'title'
]
}
end
shared_examples
'group and project board list issues query'
do
let!
(
:board
)
{
create
(
:board
,
resource_parent:
board_parent
)
}
let!
(
:label_list
)
{
create
(
:list
,
board:
board
,
label:
label
,
position:
10
)
}
let!
(
:issue1
)
{
create
(
:issue
,
project:
issue_project
,
labels:
[
label
],
relative_position:
9
,
id:
10
)
}
let!
(
:issue2
)
{
create
(
:issue
,
project:
issue_project
,
labels:
[
label
],
relative_position:
2
,
id:
11
)
}
let!
(
:issue3
)
{
create
(
:issue
,
project:
issue_project
,
labels:
[
label
],
relative_position:
9
,
id:
12
)
}
let!
(
:issue4
)
{
create
(
:issue
,
project:
issue_project
,
labels:
[
label2
],
relative_position:
432
,
id:
13
)
}
context
'when the user does not have access to the board'
do
it
'returns nil'
do
post_graphql
(
query
,
current_user:
unauth_user
)
expect
(
graphql_data
[
board_parent_type
]).
to
be_nil
end
end
context
'when user can read the board'
do
before
do
board_parent
.
add_reporter
(
user
)
end
it
'can access the issues'
do
post_graphql
(
query
(
"id:
\"
#{
global_id_of
(
label_list
)
}
\"
"
),
current_user:
user
)
expect
(
issue_titles
).
to
eq
([
issue2
.
title
,
issue3
.
title
,
issue1
.
title
])
end
end
end
describe
'for a project'
do
let
(
:board_parent
)
{
project
}
let
(
:label
)
{
project_label
}
let
(
:label2
)
{
project_label2
}
let
(
:issue_project
)
{
project
}
it_behaves_like
'group and project board list issues query'
end
describe
'for a group'
do
let
(
:board_parent
)
{
group
}
let
(
:label
)
{
group_label
}
let
(
:label2
)
{
group_label2
}
let
(
:issue_project
)
{
create
(
:project
,
:private
,
group:
group
)
}
before
do
allow
(
board_parent
).
to
receive
(
:multiple_issue_boards_available?
).
and_return
(
false
)
end
it_behaves_like
'group and project board list issues query'
end
end
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