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
7234bb6b
Commit
7234bb6b
authored
Jul 29, 2020
by
Eugenia Grieff
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add option to query a single board list on GraphQL
parent
6336341b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
5 deletions
+35
-5
app/graphql/resolvers/board_lists_resolver.rb
app/graphql/resolvers/board_lists_resolver.rb
+14
-4
app/services/boards/lists/list_service.rb
app/services/boards/lists/list_service.rb
+2
-1
spec/graphql/resolvers/board_lists_resolver_spec.rb
spec/graphql/resolvers/board_lists_resolver_spec.rb
+19
-0
No files found.
app/graphql/resolvers/board_lists_resolver.rb
View file @
7234bb6b
...
...
@@ -6,12 +6,16 @@ module Resolvers
type
Types
::
BoardListType
,
null:
true
argument
:id
,
GraphQL
::
ID_TYPE
,
required:
false
,
description:
'Find a list by its ID'
alias_method
:board
,
:object
def
resolve
(
lookahead:
nil
)
def
resolve
(
lookahead:
nil
,
id:
nil
)
authorize!
(
board
)
lists
=
board_lists
lists
=
board_lists
(
id
)
if
load_preferences?
(
lookahead
)
List
.
preload_preferences_for_user
(
lists
,
context
[
:current_user
])
...
...
@@ -22,8 +26,8 @@ module Resolvers
private
def
board_lists
service
=
Boards
::
Lists
::
ListService
.
new
(
board
.
resource_parent
,
context
[
:current_user
])
def
board_lists
(
id
)
service
=
Boards
::
Lists
::
ListService
.
new
(
board
.
resource_parent
,
context
[
:current_user
]
,
list_id:
extract_list_id
(
id
)
)
service
.
execute
(
board
,
create_default_lists:
false
)
end
...
...
@@ -34,5 +38,11 @@ module Resolvers
def
load_preferences?
(
lookahead
)
lookahead
&
.
selection
(
:edges
)
&
.
selection
(
:node
)
&
.
selects?
(
:collapsed
)
end
def
extract_list_id
(
gid
)
return
unless
gid
.
present?
GitlabSchema
.
parse_gid
(
gid
,
expected_type:
::
List
).
model_id
end
end
end
app/services/boards/lists/list_service.rb
View file @
7234bb6b
...
...
@@ -8,7 +8,8 @@ module Boards
board
.
lists
.
create
(
list_type: :backlog
)
end
board
.
lists
.
preload_associated_models
lists
=
board
.
lists
.
preload_associated_models
params
[
:list_id
].
present?
?
lists
.
where
(
id:
params
[
:list_id
])
:
lists
# rubocop: disable CodeReuse/ActiveRecord
end
end
end
...
...
spec/graphql/resolvers/board_lists_resolver_spec.rb
View file @
7234bb6b
...
...
@@ -57,6 +57,25 @@ RSpec.describe Resolvers::BoardListsResolver do
expect
(
lists
.
count
).
to
eq
3
end
end
context
'when querying for a single list'
do
it
'returns specified list'
do
list
=
resolve_board_lists
(
args:
{
id:
global_id_of
(
label_list
)
}).
items
expect
(
list
).
to
eq
[
label_list
]
end
it
'returns empty result if list is not accessible found'
do
external_group
=
create
(
:group
,
:private
)
external_board
=
create
(
:board
,
resource_parent:
external_group
)
external_label
=
create
(
:group_label
,
group:
group
)
external_list
=
create
(
:list
,
board:
external_board
,
label:
external_label
)
list
=
resolve_board_lists
(
args:
{
id:
global_id_of
(
external_list
)
}).
items
expect
(
list
).
to
eq
List
.
none
end
end
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